I want to test a nodejs app crash, need the process stop, not just throw some errors. is there a simple way to do it programattically?
app.get('/crash', function() {
//do something to crash it
})
thanks!
Try this:
app.get('/crash', function() {
process.nextTick(function () {
throw new Error;
});
})
process.exit(1)
http://nodejs.org/api/process.html#process_process_exit_code
process.kill(process.pid)
http://nodejs.org/api/process.html#process_process_kill_pid_signal
Both will exit the process.