zapty / forever-service

Provision node script as a service via forever, allowing it to automatically start on boot, working across various Linux distros and OS
https://github.com/zapty/forever-service
MIT License
594 stars 65 forks source link

Service does not start on boot on Raspbian #21

Closed alexbbb closed 9 years ago

alexbbb commented 9 years ago

How to reproduce the error: Raspbian wheezy on RaspberryPi Model B, with node.js 0.10.36 for ARM got from here: http://node-arm.herokuapp.com/node_0.10.36_armhf.deb, forever 0.14.1 and forever-service 0.4.4. Run this as root:

apt-get install wget
wget http://node-arm.herokuapp.com/node_0.10.36_armhf.deb
dpkg -i node_0.10.36_armhf.deb
npm install -g forever
npm install -g forever-service

Then create this little app:

var express = require('express');
var app = express();

app.get('/', function(req, res){
  res.send('hello world');
});

app.listen(3000);

and install it as a service:

forever-service install myservice --script app.js -p $(dirname "$(which forever)")

Reboot the raspberry and at boot the service will not get started.

To make it work, the only way I've found so far is to manually edit /etc/init.d/myservice script and add:

# Add node, npm and forever path
export PATH=/usr/local/bin:$PATH

before:

# Check if any of $pid (could be plural) are running
alexbbb commented 9 years ago

Also tried setting the command line parameter

-c /usr/local/bin/node

on each forever call, without exporting PATH, but it doesn't work

arvind-agarwal commented 9 years ago

I have done some changes in 0.4.5 to allow -e env variables to be setup as global variables rather than specific to forever command line.

So now you can use -e "PATH=/usr/local/bin:\$PATH" as the parameter in forever-service cli to add the PATH variable to your startup script

alexbbb commented 9 years ago

@arvind-agarwal it works like a charm! Just updated forever-service and tried it! Awesome job, thank you!