coreybutler / node-windows

Windows support for Node.JS scripts (daemons, eventlog, UAC, etc).
Other
2.8k stars 356 forks source link

maxRestarts does not seem to work correctly #149

Closed SamVerschueren closed 7 years ago

SamVerschueren commented 7 years ago

In the Don't DOS yourself section, I found out about maxRetries and maxRestarts.

From what I understand, maxRestarts works in a 60 second timewindow. If this is set to 3 (which is the default), it will restart 3 times per 60 seconds. Does this mean it should try to restart 3 times again the 2nd 60 seconds and again for the 3rd 60 seconds? This does not seem to work. It just tries to restart 3 times and that's it.

coreybutler commented 7 years ago

maxRestarts is a cap to prevent rogue processes. It will automatically try to restart up to maxRestarts times only for the first 60 seconds. The thinking behind this is if the app fails too many times within the first minute, there's likely a bug in the app and it should crash. The maxRestarts option is just a way to provide developers control over what that limit should be.

SamVerschueren commented 7 years ago

And can you elaborate on maxRetries then?

coreybutler commented 7 years ago

maxRetries is essentially the same thing without the 60 second time limit.

maxRestarts is useful for forcing a crash when there are programming errors, which tend to show up when a process first launches. maxRetries is useful when a process is pretty well trusted, but encounters an unforeseen critical edge case at some point down the road. An example of this would be an API with a logic problem, as opposed to a technicality... or perhaps an API that cannot connect to another resource (such as a credit card processor or an API where your credentials have changed).

SamVerschueren commented 7 years ago

Alright. Thanks for the clear explanation! Might be worth adding to the README as it wasn't entirely clear. At least to me it wasn't.