Node Server crashes after few hours

穿精又带淫゛_ 提交于 2019-11-29 02:34:46
Edgar Zakaryan

If you have large number of users most probably you are hitting systems maximum number of requests queued to listen socket. If you are sure your server can handle the load you can increase from default 128 to something 1024.

And yes, increase the ulimit, so system can handle more load, but don't set to unlimited, just check what is enough to handle current load.

Also go through this Increasing the maximum number of tcp/ip connections in linux will get some helpful info too

This is probably not the ideal answer but using forever-service with nodemon will ensure your server restarts after it crashes.

This is the command that worked for me. I'm including it because getting forever-service and nodemon to play well can be tricky.

It does the following: everytime a json or raml file in the applications dist/assets folder is modified, wait 10 seconds and then restart the node app (server.js script):

$ forever-service install raml --script server.js -f " -c nodemon" -o " --delay 10 --watch dist/assets -e json,raml --exitcrash" -e "PATH=/usr/local/bin:$PATH"

Then I can run:

$ service raml start|stop|restart|status

I can also have the service start on server reboot with the chkconfig utility:

$ chkconfig --add raml
$ chkconfig raml on
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!