Last active
August 20, 2024 01:19
-
-
Save patoi/f725a9a39d0145bcda4c3796b6419db7 to your computer and use it in GitHub Desktop.
Using systemd for nodejs process with nvm
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=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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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