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
595 stars 65 forks source link

warning: possible EventEmitter memory leak detected #20

Closed alexbbb closed 9 years ago

alexbbb commented 9 years ago

When I executed:

forever-service install myservice --script app.js

on my RaspberryPi Model B (512MB RAM) running on Raspbian with kernel 3.12.28+ #709 PREEMPT, node.js 0.12 installed from http://node-arm.herokuapp.com/node_latest_armhf.deb and forever 0.14.1 I got this error:

forever-service version 0.4.4

(node) warning: possible EventEmitter memory leak detected. 11  listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
    at Command.addListener (events.js:179:15)
    at Command.option (/usr/local/lib/node_modules/forever-service/node_modules/commander/index.js:327:8)
    at /usr/local/lib/node_modules/forever-service/bin/forever-service:40:4
    at Walker.<anonymous> (/usr/local/lib/node_modules/forever-service/lib/platforms.js:28:3)
    at Walker.emit (events.js:104:17)
    at Walker.doneOne (/usr/local/lib/node_modules/forever-service/node_modules/walker/lib/walker.js:109:35)
    at /usr/local/lib/node_modules/forever-service/node_modules/walker/lib/walker.js:99:12
    at FSReqWrap.oncomplete (fs.js:99:15)

Tried it also on a Debian 7.8.0 32 bit on another box, but everything works fine and no errors are shown. On the raspberry the service does not automatically start on boot even if it's present in the rc.d levels, but it works if I start it manually. I'll try with other node.js versions also and I will report it here.

alexbbb commented 9 years ago

The warning does not occur when I use node 0.10.36 with forever 0.14.1 and forever-service 0.4.4 on Raspbian wheezy, but the service fails to auto start on reboot. When I manually execute the command (as root):

service myservice start

everything works, but I wonder why it does not start automatically. Nothing gets shown in the log, even if I redicet the forever output to the service log file. Tried also with a crontab job:

@reboot /usr/local/bin/forever start -c /usr/local/bin/node path/to/my/app.js

but the service does not get started.

This my source code:

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

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

app.listen(3000);
alexbbb commented 9 years ago

Finally I've found where the problem was! After seeing dmesg log I've discovered that the init.d script was unable to find forever at boot on Raspbian. Probabily the PATH variable gets set or updated after that the script gets launched at boot, so to make it work I've simply added:

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

before:

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

@alexbbb For specifying path for forever you can use -p or --foreverPath command line option with forever-service.

Are all your issues resolved? If not, I would recommend posting new issue for each unique issue.

alexbbb commented 9 years ago

@arvind-agarwal thank you The issue of service not starting at boot isn't solved on Raspbian by setting the forever absolute path using the command line option (-p or --foreverPath). If I don't explicitly export PATH like in my previous post, the service does not start. node.js is in the same path (/usr/local/bin) and probabily is not found by forever at boot, so it doesn't work. If I manually start the service, it works.

When using forever-service with node 0.12 and forever 0.14.1, the warning message I posted still gets shown, so on my RaspberryPi I've decided to use node 0.10.36 for the moment.

alexbbb commented 9 years ago

Made a separate issue for the automatic start of the service on boot: #21 . Leave this one for the warning message

arvind-agarwal commented 9 years ago

@alexbbb Is the above warning, preventing you from using forever-service with node 0.12 on raspbian? I am unable to test it in raspbian currently.

alexbbb commented 9 years ago

@arvind-agarwal I'll do some tests on my Raspberry Model B using the latest Raspbian and node 0.12 as soon as I can and I'll report the results here

alexbbb commented 9 years ago

Finally I got some time and tested the latest version of forever-service with node.js 0.12.1 on my raspberry Pi 2. Apart the warning message, everything is working without errors.

arvind-agarwal commented 9 years ago

Thanks for checking, I will close the issue for now in that case.