Skip to content

Instantly share code, notes, and snippets.

@ryanburnette
Last active July 9, 2019 03:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanburnette/a008fc7bcebda4e7a7335d1f304c6cfe to your computer and use it in GitHub Desktop.
Save ryanburnette/a008fc7bcebda4e7a7335d1f304c6cfe to your computer and use it in GitHub Desktop.
Notes on running NodeJs as a systemd service
[Unit]
Description=service
After=network.target
[Service]
Type=simple
User=ubuntu
WorkingDirectory=/opt/service
ExecStart=/bin/bash -c 'exec bin/node app.js 2>&1 >> logs/console.log'
Restart=always
[Install]
WantedBy=multi-user.target
@coolaj86
Copy link

You may want Restart=always because when v8 crashes it gives a success status code.

@ryanburnette
Copy link
Author

ryanburnette commented Jan 19, 2019

@coolaj86 Thanks for the insight. Done.

@ryanburnette
Copy link
Author

ryanburnette commented Jan 29, 2019

@ryanburnette
Copy link
Author

The last comment about logging isn't working as intended. It also requires that I use Ubuntu 18.04, which I don't have the ability to do in all my environments.

I'm going to try this approach next. https://www.axllent.org/docs/view/nodejs-service-with-systemd/#comment-3322013904

@ryanburnette
Copy link
Author

@coolaj86 just DEPRECATED this approach in favor of https://git.coolaj86.com/coolaj86/go-serviceman

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment