Failed to start systemd node application

I have a node application that I am trying to add as a service, the application works fine if I go to the directory where it is installed and does node start.js , but when I do systemctl start app , it just freezes for several minutes then journalctl -u darknet shows:

 Dec 24 01:46:33 Skynet systemd[1]: Started darknet. Dec 24 01:46:33 Skynet systemd[1]: Starting darknet... Dec 24 01:46:34 Skynet darknet[32246]: module.js:434 Dec 24 01:46:34 Skynet darknet[32246]: return process.dlopen(module, path._makeLong(filename)); Dec 24 01:46:34 Skynet darknet[32246]: ^ Dec 24 01:46:34 Skynet darknet[32246]: Error: Module version mismatch. Expected 46, got 51. Dec 24 01:46:34 Skynet darknet[32246]: at Error (native) Dec 24 01:46:34 Skynet darknet[32246]: at Object.Module._extensions..node (module.js:434:18) Dec 24 01:46:34 Skynet darknet[32246]: at Module.load (module.js:343:32) Dec 24 01:46:34 Skynet darknet[32246]: at Function.Module._load (module.js:300:12) Dec 24 01:46:34 Skynet darknet[32246]: at Module.require (module.js:353:17) Dec 24 01:46:34 Skynet systemd[1]: darknet.service: main process exited, code=exited, status=1/FAILURE Dec 24 01:46:34 Skynet systemd[1]: Unit darknet.service entered failed state. Dec 24 01:46:34 Skynet systemd[1]: darknet.service failed. 

This is my .service file:

 [Unit] Description=darknet After=network.target [Service] ExecStart=/usr/bin/node /home/botty/Darknet/start.js Restart=always RestartSec=180 StandardOutput=syslog StandardError=syslog SyslogIdentifier=darknet User=botty Group=botty Environment=NODE_ENV=production WorkingDirectory=/home/botty/Darknet [Install] WantedBy=multi-user.target 

I tried to start this process as a regular user and root, and it works fine. But no matter what I try to do, it gives errors if you start with systemd.

0
linux systemd
Dec 23 '16 at 23:48
source share
2 answers

Contrary to popular belief, systemd is very different from the traditional concept of Unix initialization. This is explained in much more detail here and here . I noticed that many people ask about problems running Node with systemd and rarely get any solutions. My recommendation would be to use traditional SysV init or Upstart scripts, which also work without surprises when you see that you cannot do something with systemd. I have never seen situations where a Node application could not be easily launched using Upstart or SysV scripts, but I saw problems with systemd. I have heard that this is especially problematic for clustering and other more complex deployment scenarios. Just follow the Unix philosophy and use simple tools that do one thing and do it well. Initiated scripts are not that complicated.

See also:

  • create express systemd nodejs generator
+1
Dec 23 '16 at 23:58
source share

I had this problem. I did not use the same version of node in systemd

 $ which node /usr/local/bin/node 

Replacing /usr/bin/node with /usr/local/bin/node in ExecStart fixed for me.

0
Jul 30 '17 at 9:16
source share



All Articles