Skip to content

Systemd Service (Linux)

TIP

If you installed using the installation script, then you can safely ignore this page. The installation script has already configured the systemd services for you.

We can always use an ssh client to connect to the Linux server and run any command. However, when we disconnect the SSH, any program that is running will be stopped too. Also it is not practical to manually start the program each time the server is rebooted.

Therefore, we can configure the systemd services for MCSManager to start with the system and keep running in the background.

If you installed MCSManager manually, we recommend that you configure a systemd service for MCSManager.

Sample Configuration

Daemon

vim /etc/systemd/system/mcsm-daemon.service

[Unit]
Description=MCSManager Daemon

[Service]
WorkingDirectory=/opt/mcsmanager/daemon
ExecStart=<NodeJS installation path>/bin/node app.js
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

[Install]
WantedBy=multi-user.target

Web

vim /etc/systemd/system/mcsm-web.service

[Unit]
Description=MCSManager Web

[Service]
WorkingDirectory=/opt/mcsmanager/web
ExecStart=<NodeJS installation path>/bin/node app.js
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

[Install]
WantedBy=multi-user.target

Commands

Restart:systemctl restart mcsm-{daemon,web}.service

Start:systemctl start mcsm-{daemon,web}.service

Stop:systemctl stop mcsm-{daemon,web}.service

Disable:systemctl disable mcsm-{daemon,web}.service

Enable:systemctl enable mcsm-{daemon,web}.service

Panel Permission

If not set, MCSManager will run as the root user by default. This is not advised as it will bring extra risks to the host. It is recommended to use a separate user when starting MCSManager.

  1. Use the useradd, chmod, chown commands to create a user and set permissions.
  2. Add User=<user> to the [Service] section.
  3. Reload systemd and restart the service(s).