I've deployed my first Node.js app on OpenShift's free tier, and it works great.
Will OpenShift automatically restart my Node app when it crashes, or do I have to set up Forever.js? I tried setting it up, and it would not work. After running node_modules/forever/bin/forever start app.js
(working dir was app-root/repo
, with local copy of forever
) I got this output:
warn: --minUptime not set. Defaulting to: 1000ms
warn: --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms
info: Forever processing file: app.js
fs.js:240
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: ENOENT, no such file or directory '/var/lib/openshift/5397416f5004466c0b000080/.forever/VQMF.log'
at Object.openSync (fs.js:240:18)
at Object.startDaemon (/var/lib/openshift/5397416f5004466c0b000080/app-root/runtime/repo/node_modules/forever/lib/forever.js:406:14)
at /var/lib/openshift/5397416f5004466c0b000080/app-root/runtime/repo/node_modules/forever/lib/forever/cli.js:258:13
at /var/lib/openshift/5397416f5004466c0b000080/app-root/runtime/repo/node_modules/forever/lib/forever/cli.js:145:5
at Object.onplete (/var/lib/openshift/5397416f5004466c0b000080/app-root/runtime/repo/node_modules/forever/lib/forever.js:358:11)
So, does OpenShift manage my app's health for me, or will I need to get Forever working? If so, any idea as to the error I got?
I've deployed my first Node.js app on OpenShift's free tier, and it works great.
Will OpenShift automatically restart my Node app when it crashes, or do I have to set up Forever.js? I tried setting it up, and it would not work. After running node_modules/forever/bin/forever start app.js
(working dir was app-root/repo
, with local copy of forever
) I got this output:
warn: --minUptime not set. Defaulting to: 1000ms
warn: --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms
info: Forever processing file: app.js
fs.js:240
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: ENOENT, no such file or directory '/var/lib/openshift/5397416f5004466c0b000080/.forever/VQMF.log'
at Object.openSync (fs.js:240:18)
at Object.startDaemon (/var/lib/openshift/5397416f5004466c0b000080/app-root/runtime/repo/node_modules/forever/lib/forever.js:406:14)
at /var/lib/openshift/5397416f5004466c0b000080/app-root/runtime/repo/node_modules/forever/lib/forever/cli.js:258:13
at /var/lib/openshift/5397416f5004466c0b000080/app-root/runtime/repo/node_modules/forever/lib/forever/cli.js:145:5
at Object.onplete (/var/lib/openshift/5397416f5004466c0b000080/app-root/runtime/repo/node_modules/forever/lib/forever.js:358:11)
So, does OpenShift manage my app's health for me, or will I need to get Forever working? If so, any idea as to the error I got?
Share Improve this question asked Jun 24, 2014 at 19:18 JeffJeff 12.2k14 gold badges85 silver badges155 bronze badges 1- Perfect question, exactly what I need to know moving over from Modulus (which also restarts your app). Modulus also has the option to send you an email, anybody know if OpenShift can do that? (It doesn't look like node-supervisor has that option) – user949300 Commented Dec 26, 2014 at 17:06
2 Answers
Reset to default 6Yes, OpenShift does automatically restart your Node app when it crashes. OpenShift doesn't use forever.js but it uses node-supervisor. Your can test it by requiring something that doesn't exist. Fix it quick though because the log can grow fast restarting the app. Here is the log in nodejs.log on OpenShift which shows that it's running node-supervisor:
DEBUG: Running node-supervisor with
DEBUG: program 'server.js'
DEBUG: --watch '/var/lib/openshift/53a9e06ae0b8cde26300008e/app-root/data/.nodewatch'
DEBUG: --ignore 'undefined'
DEBUG: --extensions 'node|js|coffee'
DEBUG: --exec 'node'
DEBUG: Starting child process with 'node server.js'
DEBUG: Watching directory '/var/lib/openshift/53a9e06ae0b8cde26300008e/app-root/data/.nodewatch' for changes.
Currently, OpenShift's default behavior involves using supervisor
to start, watch, and restart your nodejs applications.
Here is a quick outline of the various init options for nodejs:
- If your app includes a valid
package.json
file with amain
entry (containing the name of your server script), then OpenShift will initialize your app by usingsupervisor
to start that script. - If your app includes the
force_npm_deploy
marker file (an empty file in.openshift/markers/use_npm
) - then OpenShift will just runnpm start
. This runs whatever is defined in yourpackage.json
file'sscripts.start
entity. - If all else fails, OpenShift will try to run
server.js
usingsupervisor
(as a fallback option).
Some additional notes are available here: https://www.openshift./blogs/10-reasons-openshift-is-the-best-place-to-host-your-nodejs-app#npm