Page tree

SAYMON документация

Skip to end of metadata
Go to start of metadata

This article describes the way to start the program complex via the process manager PM2.

Setting up PM2

On the host with the program complex install PM2 using the command:

sudo npm install -g pm2

Actor configuration

For all of actors set in-memory mode in the file /etc/saymon/actors.json. For instance:

"RestServerWorkerActor": {
    "mode": "in-memory",
    "onCrash": "respawn"
  }

Service disabling

If the program complex has been started as a service, it is necessary to stop and disable the service.

Command to stop the service:

sudo service saymon-server stop

Systemctl command to disable the service:

sudo systemctl disable saymon-server

Init command to disable the service:

rm /etc/init/{saymon-server.conf,saymon-server-binary.conf}

Start program complex via PM2

In order to start the program complex via PM2 execute the command:

sudo -Hu saymon pm2 start /usr/local/saymon/server/ecosystem.config.js

In order to set automatic start of the services when the OS is booted, execute the command:

sudo -Hu saymon pm2 startup

Setting up logs

Logs for each actor is recorded to the folder /home/saymon/.pm2/logs.

In order to set up log rotation, create the settings file /etc/logrotate.d/pm2-saymon and add to it the following content:

/home/saymon/.pm2/pm2.log /home/saymon/.pm2/logs/*.log {
  maxsize 100M
  daily
  missingok
  rotate 3
  compress
  notifempty
  copytruncate
}

Work with actors

In order to check statuses of the actors execute the command:

sudo -Hu saymon pm2 status

Monitoring of work of the actors in real-time mode:

sudo -Hu saymon pm2 monit

In order to stop/start/restart one actor or all of the actors the following commands are used:

sudo -Hu saymon pm2 start all | start all of the actors
sudo -Hu saymon pm2 restart all | restart all of the actors
sudo -Hu saymon pm2 stop all | stop all of the actors

sudo -Hu saymon pm2 start 4 5 | start actors under the numbers 4 and 5
sudo -Hu saymon pm2 restart 4 5 | restart actors under the numbers 4 and 5
sudo -Hu saymon pm2 stop 4 5 | stop actors under the numbers 4 and 5

In order to scale the actors execute the command:

sudo -Hu saymon pm2 scale saymon-rest-server 4

where:

  • saymon-rest-server is the name of the actor,
  • 4 is the necessary amount of actors.

Restarting the program complex is not obligatory.

  • No labels