Comparing version 0.1.6 to 0.1.7
@@ -195,2 +195,9 @@ 'use strict'; | ||
}); | ||
process.on('exit', function() | ||
{ | ||
if (!shuttingDown && self.options.showErrors) | ||
{ | ||
self.log.warning('Unexpected exit, please see documentation: https://github.com/alexfernandez/inits#unexpected-exit'); | ||
} | ||
}); | ||
} | ||
@@ -197,0 +204,0 @@ if (self.options.catchSignals) |
{ | ||
"name": "inits", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"description": "Init system for Node.js.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/alexfernandez/inits", |
@@ -53,2 +53,5 @@ [](http://travis-ci.org/alexfernandez/inits) | ||
An additional advantage of using `inits` is that all initialization code runs in a domain, | ||
thus catching errors and uncaught exceptions. | ||
## API | ||
@@ -284,2 +287,21 @@ | ||
### Unexpected Exit | ||
In Node.js v0.12.x and io.js, there is an event | ||
[beforeExit](https://nodejs.org/api/process.html#process_event_beforeexit) | ||
that can be used to force an ordered shutdown when there is nothing else to do | ||
and the event loop empties. | ||
However in Node.js v0.10.x there is no official way to catch this situation; | ||
the process can just finish without running the `stop` or `finish` callbacks. | ||
rather than rely on complex intervals we have opted to just | ||
let Node.js finish, but alert the user about this. | ||
If you don't want your process to exit unexpectedly you can use a `standalone` callback. | ||
You may also create a `setInterval()`, | ||
or just keep your servers running and not call `unref()` on them. | ||
In this last case your processes will keep running and only exit | ||
when the appropriate signal arrives. | ||
All of these methods will prevent your process from finishing without | ||
running the `stop` and `finish` callbacks. | ||
## Full example | ||
@@ -286,0 +308,0 @@ |
27654
12
672
367