To setup a node app as a systemd service and get it being reloaded each time you change code files use the following. This approach requires THREE files:
- myapp-node.service (where your node server is started)
- myapp-node-watcher.service (where your node server is restarted when changes in files are made)
- myapp-node-watcher.path (that checks if any file is changed)
Change the name to something meaningful but keep in mind that the *-watcher.service and the *-watcher.path must have the same name
Do it all as root or, better, as superuser.
After this issue the command systemctl status myapp-node -l to check if myapp is running. Change a file on the directory defined at the last file wait a sec and do the last command again.