Cleanup ProcessHostMonarch startup, shutdown and restart logic
Closed this issue · 1 comments
The ProcessHostMonarch
is responsigble for managing the Plebean
processes.
We need to add exponential backoff to the restarting mechanism if the Plebean
process crashes.
We also need to restructure the code to make it more easy to understand and maintain.
Thank you for the task you created for this "problem" @volllly
During the implementation of the previous issue I've reviewed ProcessHostMonarch
class and I've noticed a few areas for potential improvements.
I agree with you, let's clear _plebianLogBuffer
in the Started() method to avoid any remains from previous runs for example.
We have to also focus on Restart Logic and in this case I believe it would be a good idea to adding a mechanism to limit the number of restart attempts (restart limit) to avoid the process crashing and restarting over and over again - may result in endless loops.
Another thing what you also mentioned before is code readibility I still think about that but first thing what I see is extracting the process exit logic from the anonymous function in _process.Exited to its own method. would make it easier to understand what happens when the process exits.
Currently, much of the logic is contained in an anonymous function assigned to the _process.Exited
event 😞