Deploying a server on Linux

In principle, almost any Linux distribution will work. I will show you how to work with MST using the Ubuntu 20.04 LTS distribution as an example.
It is assumed that you already have Ubuntu installed and configured. So let's go directly to setting up and running MST.

Upload the compiled MST distribution to the server

I do this using OneDrive and the wget console command.

  • Archive your distribution in any convenient way.
  • Upload it to OneDrive.
  • While in OneDrive, get a direct link to the file that can be read by the wget console command. Right-click on the file, then "Embed".
  • Here is link we get:
<iframe src="набор_символов" width="98" height="120" frameborder="0" scrolling="no"></iframe>
  • Now let's get and then change embed? to download? to get something like this:

No go to Ubuntu server and download our archive with cmd:

wget --no-check-certificate ""
  • After download your file is placed to folder you are in right now (by default, this is the folder of the user you logged in under, /home/username).

Midnight Commander

It should be noted that wget recognizes the file name in an unusual way and calls it a very long name in the download string. It is most convenient to rename it with the Midnight Commander file Manager and work in it.

# To install МС
sudo apt install mc -y
# To start МС
sudo mc

In the window that appears, go to the downloaded file, working with the arrows on the keyboard. You can switch between the left and right Windows using the tab key.

Press F6 key to rename downloaded file to be able to open it as archive. Enter any name you want and then file extension(rar, 7z, zip etc.). This must be extension under which file was archived.

Unpacking the archive

Unpack the archive to the folder from which the program will run. For example, create a folder in the /opt directory and give it a name MasterServer, or any name you want.

  • Unpack archive using the following command:
7z x имя_архива.7z -o /opt/MasterServer

The second approach is to use Midnight Commander. Start MC and open our 7z file(p7zip and/or urar must be install). Press F5 to copy everything from the archive to the desired folder (copying occurs between the left and right windows, so in one window we open the archive, and in the other we open the desired folder).

Getting permission to execute the file .x86_64

  • Go to MasterServer directory using the following command:
сd /opt/MasterServer
  • Next getting the rights to perform our executable using the following command:
sudo chmod +x ./MasterServer.x86_64
  • In this step we already may to test starting of our executable using this command:
./MasterServer.x86_64 -mstStartMaster true -mstMasterPort 5000

As you have already noticed, the command-line arguments that are required for MST systems to work can be specified immediately after the start command.

Automating the start of the MST process

If we need MST to start when the server starts / restarts, and restart in case of failures, then I suggest making the file a service on the server. This is done as follows:

  • Create a service file and immediately edit it with the command.
sudo vim /etc/systemd/system/MasterServer.service
  • In the file that opens, we write (first by pressing the "O" on the keyboard) the following:
Description=MST Server
ExecStop=/bin/kill -s INT $MAINPID
ExecStopPost=/usr/sbin/logrotate -f /opt/MasterServer/logreboot
  • Description – this is a short description of Your service / unit.
  • Type - configures the start type of the process.
  • Restart - the service will be restarted if the process is terminated or timeout is reached, except in the case of a normal service stop.
  • StandardOutput – what the server writes to the logs. If you do not set this value, the log will be written to the system logs. Similar to the command shown below. In other words, you don't need to specify this parameter if you don't need a separate log.
sudo journalctl -u MasterServer | grep MasterServer.x86_64 > MSTstandartOutput.log
  • StandardError – applies only to the service itself. Program errors are not displayed there! They are output by StandardOutput. Here will be errors if the service itself has any problems (it doesn't start, crashes, etc.).
  • ExecStart - here can be commands along with arguments that will be executed when the service starts.
  • ExecStop - here will be commands that will be executed to stop the service.
  • ExecStopPost - here will be commands that will be executed after the service is stopped.
  • WorkingDirectory – working directory of the service. If not specified, then all files that will be created by the program (e.g., nonSQL databases, etc.) will be created in the root directory of the user who will run the service (in this case, it starts using the system rights, so all files without this parameter, will be created on the system root /).

Read more about what parameters can be used type the man systemd command.

To save all changes to the MasterServer.service file, exit editing by pressing Esc and entering the command: wq.

Configuration file

As you may remember, the command line values for .We specified / MasterServer. x86_64 immediately after the file launch command .x86_64. You can also do this using the application.cfg configuration file. If this file has not been created yet, then create it with the command:

# Create and edit file
sudo vim /opt/MasterServer/application.cfg

# Just creates file that can be edited by cmd pointed above
sudo touch /opt/MasterServer/application.cfg

После создания и редактирования MasterServer.service нам нужно записать изменения для systemctl с помощью команды:

sudo systemctl daemon-reload

# Making the file run at system startup:
sudo systemctl enable MasterServer

# Then we can start MST as a service:
sudo systemctl start MasterServer

# Then is followed by service commands that you can use as needed

# To stop the service, enter the command:
sudo systemctl stop MasterServer

# To view the service status, use the command:
sudo systemctl status MasterServer

# To restart the service, enter the command:
sudo systemctl restart MasterServer

If everything was done correctly, then our server should work. You can check if it is reachable on the website by writing the following path:

  • ws:// or wss:// - depending on the installed certificate.
  • your_server_ip - IP или URL адрес вашего сервера
  • port - the port that your server listens on for the MasterServer service
  • echo - a service running in MST to check the server response to the client


You can read more about log file rotation on this page or run the man logrotate command.

To be continued...