Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Implement background process manager #5826
LXD currently spawns a number of background processes and then attempts to track them as they run. This isn't done very consistently and is the source of quite a bit of code duplication.
Instead we should add a new package that provides functions to both spawn a background process and keep track of it as well as import existing background processes and keep track of those too.
The process struct should then let us stop, start, restart, reload, signal, wait for the process.
The process monitoring logic should auto-respawn processes up to a limit within a reasonable time period and when available should make use of pidfds as a race free way of keeping track of those processes.
Initial users should be:
For this issue, we'd like a completely standalone Go package that we could then transition some of our code over. So rather than directly modifying LXD from the start, this should start as a new Go package under our
Once we think it covers all we need to spawn/stop/restart/track background processes on Linux, we can add some unit tests for it, clean the package up to be of the same standard as our newer standalone packages and then have separate commits or even a separate branch making use of it to drive
Down the line, we'll want to make this use