简体   繁体   中英

NodeJS - Keep my App running with Forever

Currently, I have a NodeJS service running on my server. It provides a RestAPI thanks to HAPI.JS

This service run permanently with forever executed in upstart script but I got some trouble.

Sometimes, the service have an error like this :

Debug: internal, implementation, error 
    TypeError: Uncaught error: Cannot call method 'replace' of undefined....

At this moment, server is completly down and never restart :(

I need a 100% stable service that why I have to restart it when an error appears.

My Question :

How can I restart NodeJS Service with forever when errors occured ?

Run you app with pm2 instead of forever. Pm2 will restart the node server even after uncaught exceptions.

If the process fails on startup then it won't restart automatically. You can configure the minimum uptime --minUptime flag.

You can then use the --watch flag to watch for changes of the fix.

However, the specific error you're receiving wouldn't normally stop the Hapi process which would suggest this isn't a forever issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM