isaacs/npm-www — pull request #80 by bahamas10 (2012-08-02 18:51:12+00:00)
Title: Changing svc.startd wait model to contract

This changes the model for the service restarter `svc.startd` from "wait/child" to "contract". I would argue that this model is better for long running services, as it can correctly handle error conditions by transitioning the service to maintenance mode.

From svc.startd(1M)

> "Wait" model services are restarted whenever the child process associated with the service exits. A child process that exits is not considered an error for "wait" model services, and
> repeated failures do not lead to a transition to maintenance state.

With the current model, if the service were to fail repeatedly (say, `server.js` is not found, or has a syntax error), `svc.startd` would attempt to restart it repeatedly. Speaking from experience, this can cause bad things to happen. Besides the service being repeatedly restarted just to fail again, all of this will get logged, creating unnecessary IO, and the server will just experience general lagginess (which will manifest itself as latency in the app).

The change I propose also includes 2 new properties, `critical_failure_count` and `critical_failure_period`. These translate to "if the process restarts for more than `count` times in `period` seconds, transition to maintenance and give up`.