Stono
Stono

Reputation: 2337

Nodejs, Forever and SystemD startup issue

I'm trying to get forever to start a simple nodejs application at startup as a proof of concept using systemd and for the life of me can't get it to work.

It works absolutely fine if I do: systemctl start simple-empty-app.service

However if I restart the system it doesn't even try to load, there doesn't seem to be anything in syslog indicating it is even attempting it (but there are some other systemd startup messages, so I know systemd is doing its stuff...).

My .service script looks like this:

[Unit]
Description=This is an empty tiny app for testing the nodejs deployment agent

[Service]
StandardOutput=syslog
SyslogIdentifier=simple-empty-app
Type=forking
Environment=ENV=production
Environment=PATH=/usr/bin:/usr/local/bin
WorkingDirectory=/var/opt/nodejs-agent/node_modules/simple-empty-app
ExecStart=/usr/local/bin/forever start --pidFile /var/run/simple-empty-app.pid /var/opt/nodejs-agent/node_modules/simple-empty-app/app.js
ExecStop=/usr/local/bin/forever stop /var/opt/nodejs-agent/node_modules/simple-empty-app/app.js
PIDFile=/var/run/simple-empty-app.pid
User=root

A systemctl status simple-empty-app.service after a reboot shows this:

simple-empty-app.service - This is an empty tiny app for testing the nodejs deployment agent
Loaded: loaded (/var/opt/nodejs-agent/node_modules/simple-empty-app/simple-empty-app.service; linked)
Active: inactive (dead)
CGroup: name=systemd:/system/simple-empty-app.service

And just to prove it starts manually:

root@karls-debian:~# systemctl start simple-empty-app.service
root@karls-debian:~# systemctl status simple-empty-app.service
simple-empty-app.service - This is an empty tiny app for testing the nodejs deployment agent
Loaded: loaded (/var/opt/nodejs-agent/node_modules/simple-empty-app/simple-empty-app.service; linked)
Active: active (running) since Fri, 11 Apr 2014 17:34:24 +0100; 4s ago
Process: 1558 ExecStart=/usr/local/bin/forever start --pidFile /var/run/simple-empty-app.pid /var/opt/nodejs-agent/node_modules/simple-empty-app/app.js (code=exited, status=0/SUCCESS)
Main PID: 1566 (node)

Anyone got any ideas? If it helps, obviously I've retrospectively installed systemd and systemd-sysv from the debian repo as it isn't systemd out the box. And i'm on Wheezy

Upvotes: 3

Views: 4548

Answers (1)

Stono
Stono

Reputation: 2337

Fixed it, just needed the following section:

[Install] WantedBy=multi-user.target

Upvotes: 3

Related Questions