Add support for plugging in a script on the master process. #83
+16
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I doubt my change is perfect yet, and lacks tests, but wanted to initiate a conversation on whether or not the ability to customize the code running in the master process could fit into the core features of naught. A very simple use case is to manage log file writing, but any place where you may want some shared state between workers this could help. Log4Js for instance has an example for clustered mode:
https://github.com/nomiddlename/log4js-node/wiki/Multiprocess
But you obviously need to support adding some code into the master process. I've done this by allow a master process script file to be passed to naught, and then requiring it in. It can export a "online" function to be notified when new workers start. Probably needs a more developed contract/API, so open to ideas on changes. It has been working well for us to support master process file logging.