#add config file
sudo echo "[Unit]
Description=Randdrop
After=network.target
[Service]
Environment=NODE_ENV=production
Type=simple
User=root
WorkingDirectory=/root/randdrop-api
ExecStart=/usr/bin/node dist/index.js
Restart=always
RestartSec=3
# Node.js application logs
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=randdrop
[Install]
WantedBy=multi-user.target" > /lib/systemd/system/randdrop-api.service
# turn off current randdrop process so you dont get port conflict afterwards
# reload deamon to take the new service into account
sudo systemctl daemon-reload
# make sure service starts on machine boot
sudo systemctl enable randdrop-api
sudo systemctl start randdrop-api
# check logs and status
sudo systemctl status randdrop-api
journalctl -u randdrop-api