Skip to content

Instantly share code, notes, and snippets.

@patoi
Last active August 20, 2024 01:19
Show Gist options
  • Save patoi/f725a9a39d0145bcda4c3796b6419db7 to your computer and use it in GitHub Desktop.
Save patoi/f725a9a39d0145bcda4c3796b6419db7 to your computer and use it in GitHub Desktop.
Using systemd for nodejs process with nvm
[Unit]
Description=Document Server Daemon
[Service]
Type=forking
Environment=NODE_VERSION=12
WorkingDirectory=/home/your_user/your_node_app_dir
ExecStart=/home/your_user/.nvm/nvm-exec npm start
StandardOutput=
User=your_user
[Install]
WantedBy=multi-user.target
@patoi
Copy link
Author

patoi commented Oct 22, 2019

You need to install at least one Node.js version: nvm install --lts by your_user account ( https://github.com/nvm-sh/nvm ).

First: sudo su

Edit:

nano /etc/systemd/system/docserver.service

Reload after editing:

systemctl daemon-reload

Start, stop, restart:

systemctl start|stop|restart docserver.service

Log:

journalctl -fu docserver.service

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