I've got the following service that I'm trying to run on startup. I've made a service file:
[Unit]
Description=Denny node server start
[Service]
WorkingDirectory=/home/root
Type=forking
Restart=always
StandardOutput=syslog
User=nobody
Group=nobody
RemainAfterExit=true
ExecStart=/usr/bin/node /home/root/server.js
KillMode=process
Environment=NODE_ENV=production
[Install]
WantedBy=multi-user.target
I've dropped this in /etc/systemd/system/ then I run
systemctl daemon-reload
then
systemctl start denny
Nothing. No server is started up. Ok, I check on it:
root@denny:~# systemctl status denny
I get back:
● denny.service - Denny node server start
Loaded: loaded (/etc/systemd/system/denny.service; enabled)
Active: active (exited) (Result: exit-code) since Fri 2015-02-13 17:13:21 UTC; 29min ago
Main PID: 225 (code=exited, status=8)
CGroup: /system.slice/denny.service
Feb 13 17:41:40 denny systemd[1]: Started Denny node server start.
I may be mis-remembering but seems to be exactly what I did on Debian and it worked fine, i.e. it kept the service running and acting as it should. Am I missing something in this .service file that would tell the default Linux for edison to keep this running?
This answer only works with the Node.js answer but a solution (and the one I went with) was to place my node application in /node_app_slot in the filesystem with the following package.json also in the /node_app_slot:
{
"name": "sample",
"description": "",
"version": "0.0.0",
"main": "main.js",
"engines": {
"node": ">=0.10.0"
},
"dependencies": {
}
}
This allows the XDK daemon to pick up and run the Node app on boot. Fairly painless and simple but not super well documented.