0

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
11
  • 1
    As far as I know, node files won't run by default/"natively". Try running /var/www/gwart/mediawiki/extensions/VisualEditor/parsoid/bin/server.js in your terminal. To fix this, run whereis node and prepend the binary path to the ExecStart= statement. Commented Dec 15, 2018 at 20:45
  • Very good point, give me 5, I think I can use this :)( Commented Dec 15, 2018 at 20:51
  • I've updated the question with the latest, but it seems to me. node ..bin/server.js will 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 could ln it? Commented Dec 15, 2018 at 21:02
  • 1
    See my first comment. Run whereis node and use the absolute path to the node binary. Commented Dec 15, 2018 at 21:03
  • 2
    ExecStart=/usr/bin/node /path/to/your/file.js should work fine. ExecStart=node /path/to/your/file.js won't work as node is not an absolute path. Commented Dec 15, 2018 at 21:13

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.