NodeJS Script killed by SIGKILL when running on Forever

vnay92 picture vnay92 · Sep 1, 2015 · Viewed 13.2k times · Source

I have a Node.JS application that does a MySQL DB access, a few HTTP requests , saves the response CSV to a file, reads that same file and writes to Cassandra. I am running it on Ubuntu 14.04 and I'm using Express, to expose a web API that does all the above tasks.

I have another application written in Node.JS which calls the API for 200 users. Since it's Node.JS, the calls are Async.

I run the Express app using :

node index.js

When I run the other script, which hits the Express API, the script runs fine for 200 users with a response:

{"status":200,"message":"Got the data and saved to the DB"}

When I run the same Express App using Forever:

forever start -w index.js

and then run the cron Script for 200 users, I get

err { [Error: socket hang up] code: 'ECONNRESET' }

and when I open the log file, this is what I found:

error: restarting script because add changed error: Forever detected script was killed by signal: SIGKILL error: Script restart attempt #5

Now that the App runs fine while running in the foreground and is killed while running in the background, does it have to do something about how much resources is allocated to a daemon process?

Should I crank up my server? Or is there any way I can allocate more resources to the Express App?

Answer

vmkcom picture vmkcom · Sep 1, 2015

Seems that you have problem with changing files or file attributes via pulling new code.

try to configure .foreverignore for hidden subdirectories, like described here

https://github.com/foreverjs/forever/issues/235

If you can't ignore or stop updating that files you need to stop using forever for watching file updates

I can recommend http://supervisord.org/ for running nodejs app on the Linux machines