Pages

How To Use The Supervisor Feature

Through the Supervisor tool, you will be able to run background scripts and programs on your own in a way that the security of your web hosting account could be guaranteed.
The Supervisor functionality is mostly used to establish real-time, two-way connections between web clients and servers over the TCP-based WebSocket Protocol.

WebSocket is a new HTML5 feature, which allows JavaScript clients to open bidirectional socket connections to a server without interruptions.

This enhances the interaction between browsers and sites and facilitates the syndication of live web content.

Here is a visual overview of how the WebSocket background process works as compared to a normal request-response client-server communication process:

Click to enlarge

As you can see in the figure above, the WebSocket protocol allows for a bidirectional communication between a client and a server.

It also permits you to get real-time server updates and to save traffic resources for regular server polling.

How do I use the Supervisor?

To make use of the Supervisor and initiate a background process in your web hosting account, you will need to create an instance.

In the Supervisor section, click on the “Create an instance” button:

Click to enlarge

When a Supervisor instance is created, a TCP port will be assigned automatically to the background application.

How to run a chat server over WebSocket – a case study

Now let’s go through the basic steps to initiating a long-running background process in your web hosting account.

In this example, we’ll set up a chat server over the WebSocket protocol, mentioned earlier in the post.

To run a chat server, you’ll first need to have it downloaded from the web.

In our case, we’ll use a chat server exemplified on the popular PHP tutorials site sanwebe.com.

First, we’ll set up a host where the chat server will be uploaded from the Hosted Domains section of your Control Panel.

Click to enlarge

Then we’ll upload the index.php file from the chat server folder to the host’s main folder using the File Manager:

Click to enlarge

In the main /home/www/ directory, create a folder for the chat server file.

In our example, the folder will be named /home/www/server/:

Click to enlarge

NOTE: The chat server file should have executable permissions such as 700 or 755.

Now let’s go to the new Supervisor section and create an instance for the background-running chat server.

In the command field, browse to the server path and then click on the Add button:

Click to enlarge

When the instance is created, you’ll see the TCP port that has been generated for you on the left:

Click to enlarge

Next, you should copy the port and then paste it into the server.php file using the text editor in the File Manager section:

Click to enlarge

Then open the index.php file and replace the default hostname with your hostname.

You should also enter the new port:

Click to enlarge

That’s it! Now you can start your chat server:

Click to enlarge

NOTE: To protect the server.php file from public access, you can set access rules using the .htaccess file.

Where is the Supervisor located?

The Supervisor functionality is located in the Advanced section of the Web Hosting Control Panel.

You can access it by clicking the shortcut icon on the index page:

Click to enlarge

Alternatively, you can navigate to the Supervisor feature using the Advanced drop-down menu: