I can recommend having a quick read through this: https://wiki.ubuntu.com/SystemdForUpstartUsers
Instead of putting your upstart config in /etc/init
you put it in /etc/systemd/system
and it has a different format. Systemd configs are called "units" and (for us) look like:
[Unit]
Description=Job that runs the {{service}} service
[Service]
Type=simple
WorkingDirectory=/home/{{service}}/current/src
ExecStart=/usr/bin/npm start
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier={{service}}
User={{service}}
Group={{service}}
Environment=NODE_ENV=production
[Install]
WantedBy=multi-user.target
Most of these are self explanatory.
Note: You HAVE to use full paths to binaries.
Type=simple
- it is ready when the process is started. You can set this to "fork" and it will be ready when it has spawned another process and the original has exited
WantedBy=multi-user.target
- adds this unit as a dependency of the "multi-user.target" unit, which is a built in unit of systemd. Essentially it allows you to specify when your unit is started/stopped
No more logrotate or tail /var/log/upstart/{{service}}.log
:
journalctl -u node-sample
Where "node-sample" is SyslogIdentifier
.
This article was also helpful: https://blog.codeship.com/running-node-js-linux-systemd/