-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Gekko Background Service With 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.
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
Enable gekko on startup:
- sudo systemctl enable gekko
That's it, really. Restart (sudo restart now) or manually start gekko using the command below.
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
Clear all but past 2 days of logs
- sudo journalctl --vacuum-time=2d
Note: You can not delete logs for a specific unit/service because all systemd unit logs are interlaced.
Reload changes made to /etc/systemd/system/gekko.service (if you tweak it after it's initial use)
- sudo systemctl daemon-reload
Hello Mike