Last active
July 9, 2019 03:27
-
-
Save ryanburnette/a008fc7bcebda4e7a7335d1f304c6cfe to your computer and use it in GitHub Desktop.
Notes on running NodeJs as a systemd service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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 Thanks for the insight. Done.
For logging...
https://gist.github.com/ryanburnette/a008fc7bcebda4e7a7335d1f304c6cfe#file-node-service-L10-L11
Read these...
https://stackoverflow.com/a/43830129/2535178
systemd/systemd#7198 (comment)
If you don't have a new enough version of systemd on Ubuntu... read this...
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
@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
You may want
Restart=always
because when v8 crashes it gives a success status code.