Skip to content

Instantly share code, notes, and snippets.

@omartrigui
Last active April 14, 2018 03:53
Show Gist options
  • Save omartrigui/db0572f18a3e30c5e0bbe047e0bade82 to your computer and use it in GitHub Desktop.
Save omartrigui/db0572f18a3e30c5e0bbe047e0bade82 to your computer and use it in GitHub Desktop.
Daemonize nodejs service using systemd
# vim /etc/systemd/system/myservice.service
[Unit]
Description=myservice-description
After=network.target
[Service]
ExecStart=/opt/myservice-location/src/node/server.js
Restart=always
User=me
Group=group
Environment=PATH=/usr/bin:/usr/local/bin
Environment=NODE_ENV=production
WorkingDirectory=/opt/myservice-location
[Install]
WantedBy=multi-user.target
# systemctl start myservice
# https://nodesource.com/blog/running-your-node-js-app-with-systemd-part-1/
# https://www.axllent.org/docs/view/nodejs-service-with-systemd/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment