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

forever-service Not working!! #82

Open Jarvis785 opened 7 years ago

Jarvis785 commented 7 years ago

i had a simple LED blink code nodejs i have tested by command :node /home/pi/blink.js (its blinking !! working..)

sudo forever-service install IOT --script /home/pi/blink.js

sudo service IOT start (it gives no error) sudo service IOT status (it says running) IOT.service - LSB: forever-service startup script for IOT Loaded: loaded (/etc/init.d/IOT) Active: active (running) since Sat 2016-10-29 20:17:00 UTC; 1min 46s ago Process: 4217 ExecStart=/etc/init.d/IOT start (code=exited, status=0/SUCCESS) CGroup: /system.slice/IOT.service └─2835 /usr/bin/nodejs /usr/lib/node_modules/forever/bin/monitor /home/pi/myblynk.js

Oct 29 20:17:00 Pi-Jarvis IOT[4217]: Service IOT already running Oct 29 20:17:00 Pi-Jarvis systemd[1]: Started LSB: forever-service startup script for IOT.

But LED not blinking !! Why ?

ame program works if i use only forever :: forever /home/pi/blink.js start !!

but forever-service not working

arvind-agarwal commented 7 years ago

Can you check the log file related to this service in /var/log and see if it has got console logs from your service?

Jarvis785 commented 7 years ago

Found the error sir !! Its showing can not find module blynk-library... (I hv included this library in node program)

But running the same file using node x.js works ...

But why in forever service it is unable to fetch the library ??

is it due to the problem that the process can't acess global library

arvind-agarwal commented 7 years ago

When provisioning the service i will usually advise to change the directory to the directory of the script and than provision the service, since this way when service is run it runs from same directory.

So i would suggest you do the following.

cd  /home/pi/ 
sudo forever-service install IOT --script blink.js
Jarvis785 commented 7 years ago

no sir .. doing cd /home/pi/ sudo forever-service install IOT --script blink.js

gave the same result !!

arvind-agarwal commented 7 years ago

In that case i cant exactly be more helpful on the issue, sometimes issue could be related to path / nodejs installation folder since services run under sudo context, and may not have exact environment (as running them normally from terminal) when you run them as sudo under service context.

So i guess you will have to do more debugging, since only thing forever-service does is invokes forever for your script. Beyond that it has no control on what goes on.

arvind-agarwal commented 7 years ago

No idea, but why don't you give it a shot.

Jarvis785 commented 7 years ago

i had deleted that IOT.log .... now installing and running IOT again ... i can't found the log file again !!