dresende/node-rack — pull request #2 by robmerrell (2012-02-28 18:39:17+00:00)
Title: workers not restarting correctly if only 2 fail within monitor's frequency

Hey there! I ran into a case where monitor.js's last_crash isn't being cleared:

```javscript
var rack = require("../lib/rack").create();

rack.on("master-start", startMaster);
rack.on("worker-start", startWorker);

rack.on("worker-error", function () {
console.log("[!] workers dying to quickly");
process.exit(1);
});

rack.monitor(10, 5000);
rack.start();

function startMaster(rack) {
console.log("[%d] master started", rack.pid);
}

function startWorker(worker) {
console.log("[%d] worker started", worker.pid);

require("http").createServer(function (req, res) {
process.exit(1)
}).listen(1337);
}
```

```bash
#! /bin/bash

curl http://localhost:1337/
curl http://localhost:1337/

for i in {1..15}
do
curl http://localhost:1337/
sleep 2
done
```

The first two requests fail within monitor's frequency time and even though the remaining 15 calls fail outside of the frequency time the last_crash is never reset. Removing clearTimeout fixes this problem. Removing it didn't seem to cause any unintentional side effects.

Thanks!
Rob