I am simply trying to start my node application as a service I am pointing to the server.js file and have that set as executable.
I would like to have this node app restarting on server reboot and be able to generally just use it as a service.
/etc/systemd/system/parsoid.service
[Unit]
Description=MediaWiki Parsoid Server
[Service]
ExecStart=/var/www/gwart/mediawiki/extensions/VisualEditor/parsoid/bin/server.js
Restart=always
User=nobody
# Note Debian/Ubuntu uses 'nogroup', RHEL/Fedora uses 'nobody'
Group=nogroup
Environment=PATH=/usr/bin:/usr/local/bin
Environment=NODE_ENV=production
WorkingDirectory=/var/www/gwart/mediawiki/extensions/VisualEditor/parsoid
[Install]
WantedBy=multi-user.target
However when checking if the service is running it does not start. The node app starts without problems by doing node /var/www/gwart/mediawiki/extensions/VisualEditor/parsoid/bin/server.js.
Errors
root@server:/etc/systemd/system# systemctl status parsoid.service
● parsoid.service - MediaWiki Parsoid Server
Loaded: loaded (/etc/systemd/system/parsoid.service; enabled; vendor preset: enabled)
Active: inactive (dead) (Result: exit-code) since Sat 2018-12-15 20:35:57 GMT; 1s ago
Process: 8565 ExecStart=/var/www/gwart/mediawiki/extensions/VisualEditor/parsoid/bin/server.js (code=exited, status=127)
Main PID: 8565 (code=exited, status=127)
Dec 15 20:35:56 server.live-servers.net systemd[1]: parsoid.service: Unit entered failed state.
Dec 15 20:35:56 server.live-servers.net systemd[1]: parsoid.service: Failed with result 'exit-code'.
Dec 15 20:35:57 server.live-servers.net systemd[1]: parsoid.service: Service hold-off time over, scheduling restart.
Dec 15 20:35:57 server.live-servers.net systemd[1]: Stopped MediaWiki Parsoid Server.
Dec 15 20:35:57 server.live-servers.net systemd[1]: parsoid.service: Start request repeated too quickly.
Dec 15 20:35:57 server.live-servers.net systemd[1]: Failed to start MediaWiki Parsoid Server.
[Edit]
Dec 15 20:57:33 server88-208-249-95.live-servers.net systemd[1]: [/etc/systemd/system/parsoid.service:5] Executable path is not absolute, ignoring: node /var/www/gwart/mediawiki/extensions/VisualEditor/parsoid/bin/server.js
Dec 15 20:57:33 server.live-servers.net systemd[1]: parsoid.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
root@server:/etc/systemd/system# /var/www/gwart/mediawiki/extensions/VisualEditor/parsoid/bin/server.js
Error while reading config file: Error: ENOENT: no such file or directory, open '/etc/systemd/system/config.yaml
/var/www/gwart/mediawiki/extensions/VisualEditor/parsoid/bin/server.jsin your terminal. To fix this, runwhereis nodeand prepend the binary path to theExecStart=statement.node ..bin/server.jswill work in the terminal, however service requires an absolute path, which means I have no way of telling it where the base path should be, in regards to getting the config.yml is. I guess I couldlnit?whereis nodeand use the absolute path to the node binary.ExecStart=/usr/bin/node /path/to/your/file.jsshould work fine.ExecStart=node /path/to/your/file.jswon't work asnodeis not an absolute path.