Supervisor - a fresh developer-friendly feature within the Hepsia Control Panel

March 23, 2016
Undoubtedly, programming demands a significant investment of time and effort.

Yet, if web hosting account holders were to experience a developer's perspective, managing tasks could become more manageable.

We've made diligent efforts to simplify fundamental website management responsibilities, such as configuring cron jobs, controlling outgoing connections, establishing Memcached/Varnish instances, and selecting a PHP version, all within the Advanced section of the Web Hosting Control Panel.

Moreover, the recently introduced Supervisor feature takes this a step ahead, enabling website proprietors to execute scripts in the background.

What does the Supervisor entail?

The core purpose of the newly introduced Supervisor functionality is to grant website owners the ability to run extended scripts or applications in the background of their web hosting environment.

Historically, the execution of background-running scripts has been restricted within our system, and this stance is maintained across the majority of web hosting platforms.

The primary concern associated with background-running scripts is their potential exploitation by hackers to compromise website owners' security. For instance, if a hacker gains access to a web hosting account through a poorly protected website, they could effortlessly employ a bot script as part of a botnet for orchestrating large-scale DDoS attacks. Consequently, the account holder becomes unwittingly involved in a vast hacking campaign through their own resources.

While background scripts do pose security risks, there are numerous legitimate use cases for them by website proprietors and developers.

In response to user requests for the ability to run background processes for ongoing content projects, we've opted to grant this privilege from a controlled environment – the Web Hosting Control Panel. This initiative has led to the creation of the Supervisor section within the Control Panel.

From this section, users can execute background scripts and applications, ensuring the security of their web hosting accounts.

One of the most common applications for background processes is operating a WebSocket server in PHP. The Supervisor functionality is primarily used to establish real-time, bidirectional connections between web clients and servers through the TCP-based WebSocket Protocol. WebSocket, an HTML5 feature, enables JavaScript clients to establish socket connections to servers without disruptions, thereby enhancing interactions between browsers and websites and facilitating the dissemination of live web content.

For instance, a WebSocket URL might appear as follows: ws://host:port/path (e.g., ws://localhost:8000/echo). After obtaining the WebSocket server (distinct from Apache), it needs to be initiated and verified to run in the background.

A WebSocket connection is initiated by dispatching a conventional HTTP request that includes an Upgrade header, indicating the client's intention to establish such a connection.

Here's an overview of how the WebSocket background process functions in comparison to the regular request-response client-server communication process.

The WebSocket protocol allows bidirectional communication between clients and servers, enabling real-time server updates and conserving resources that would otherwise be utilized for frequent server polling.

How can I employ the Supervisor?

To utilize the Supervisor feature and commence a background process within your web hosting account, you must generate an instance.

Within the Supervisor section, select the "Initiate an instance" option.

Upon creating a Supervisor instance, an associated TCP port will be allocated automatically to the background application.

Let's delve into the fundamental steps for launching an enduring background process within your web hosting account.

For this illustration, we'll walk through the process of establishing a chat server utilizing the WebSocket protocol, as previously mentioned.

To deploy a chat server, you must initially obtain the required software from the internet.

In this scenario, we will adopt a chat server model derived from the well-regarded PHP tutorials platform,

Firstly, designate a host where the chat server application will be uploaded, a task accomplished through the Hosted Domains section within your Control Panel.

Subsequently, utilize the File Manager to upload the index.php file from the chat server directory to the main directory of the designated host.

Generate a dedicated folder for the chat server file within the main /home/www/ directory. In this instance, we'll name the folder /home/www/server/

IMPORTANT: Ensure that the chat server file possesses executable permissions such as 700 or 755.

Now proceed to the newly established Supervisor section, where you will forge an instance for the background-oriented chat server.

Within the command field, navigate to the server's path and subsequently press the Add button.

Following the instance's creation, the assigned TCP port will be visibly listed on the left side.

Subsequently, copy the designated port and integrate it into the server.php file using the text editor within the File Manager.

Next, modify the index.php file by substituting the default hostname with your specific hostname. Also, input the newly acquired port.

That concludes the procedure! You are now capable of initiating your chat server.

IMPORTANT: To safeguard the server.php file against public access, consider instituting access rules through the utilization of the .htaccess file.

Where can the Supervisor be found?

The Supervisor feature is situated within the Advanced section of the Web Hosting Control Panel.

You can reach it by selecting the shortcut icon on the index page.

Alternatively, you can access the Supervisor functionality through the Advanced drop-down menu.