Được tạo bởi Blogger.

How to run Gekko as a background service on startup using systemd

There are plenty of resources on how to run a node.js service with systemd, many could likely piece this together without help. This is a clear and to the point tutorial on how I successfully accomplished this task on a Debian 9 VPS server.
For this example, I will be using the user/group admin/admin and Gekko install in ~/gekko. Replace user/group and path as necessary. If you remove the User= and Group= lines it will run as root, don't do that.

Step 1:

sudo nano /etc/systemd/system/gekko.service
[Service]
ExecStart=/usr/bin/node /home/admin/gekko/gekko.js --ui
Restart=always
RestartSec=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=gekko
User=admin
Group=admin
Environment=NODE_ENV=production

[Install]
WantedBy=multi-user.target

Step 2:

Enable gekko on startup:
sudo systemctl enable gekko
That's it, really. Restart (sudo restart now) or manually start gekko using the command below.

Other systemctl commands:

Manually start the gekko service:
sudo systemctl start gekko
Manually stop the gekko service
sudo systemctl stop gekko
Turn off gekko auto startup
sudo systemctl disable gekko
Current status of the gekko service
sudo systemctl status gekko.service
See gekko's logs
sudo journalctl -u gekko
Reload changes made to /etc/systemd/system/gekko.service (if you tweak it after it's initial use)
sudo systemctl daemon-reload
Gekko can be noisy. This will clear all but past 2 days of logs. Note: You can not delete logs for a specific unit/service because all systemd unit logs are interlaced. This will affect all unit logs!
sudo journalctl --vacuum-time=2d
    Blogger Comment
    Facebook Comment