Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Creating a systemd Service File
- >$ cd /lib/systemd/system
- >$ sudo vi /lib/systemd/system/myNode.service
- and put the following contents in it (example):
- ```sh
- [Unit]
- Description=Start app.js on my Node
- After=network.target
- [Service]
- Environment=NODE_PORT=3001
- Type=simple
- User=pi
- ExecStart=/usr/bin/node /home/pi/myApp/app.js
- Restart=on-failure
- [Install]
- WantedBy=multi-user.target
- ```
- ### Using systemctl To Control Our App
- **You have to do this whenever any of the service files change at all so that systemd picks up the new info.**
- >$ sudo systemctl daemon-reload
- **If you want to make the application start up when the machine boots, you accomplish that by enabling it**
- >$ sudo systemtl enable myNode.service
- **Other options**
- >$ sudo systemctl [status,start,stop,restart,enable,disable] myNode.service
- **List**
- >$ systemctl list-unit-files | grep enabled
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement