Copy this myapp.service
file under /etc/systemd/system
Enable service (starts at boot time)
systemctl enable myapp.service
Start service immediately
systemctl start myapp.service
Display logs of service (stdout)
journalctl -u myapp.service
Copy this myapp.service
file under /etc/systemd/system
Enable service (starts at boot time)
systemctl enable myapp.service
Start service immediately
systemctl start myapp.service
Display logs of service (stdout)
journalctl -u myapp.service
[Unit] | |
Description=MyApp Daemon | |
After=elasticsearch.service | |
[Service] | |
WorkingDirectory=/web/myapp | |
ExecStart=/opt/nodejs/bin/node index.js | |
Restart=always | |
StandardOutput=syslog | |
StandardError=syslog | |
SyslogIdentifier=myapp | |
User=www-data | |
Group=www-data | |
Environment=NODE_ENV=production | |
[Install] | |
WantedBy=multi-user.target |
Save it as
/etc/systemd/system/myapp.service
Runs at boot
systemctl enable myapp
Start it immediately
systemctl start myapp
View status
systemctl status myapp
View all logs from app stdout
journalctl -u myapp