Way to check if process is the master (parent) or worker (child)
karmakaze opened this issue · comments
We've been using this library in prod and it's working great. One thing I ended up hacking a bit in our usage was making some initialization only take place in the child worker processes and not the master parent process. Specifically we were getting duplicate initialization logs and startup metrics.
In production our service runs with systemd so we just check if the parent process id == 1
to determine if we are the master. This doesn't work when running as user processes in development.
I'd like to be able to call a package function to say whether it's the master or worker before calling server.Run
.
hi @karmakaze , we did encounter this issue as well, graceful
provides server.IsMaster
and server.IsWorker
functions. This library should be well documented soon.
Awesome! Works like a charm.
Btw, you might like this quick comparison I did of the top similar libraries.