-
Notifications
You must be signed in to change notification settings - Fork 79
Description
Background
When users build command or Build plugins create background processes, but forget to terminate them before exit, those processes will keep running until the container exits. This is a user error (bad cleanup) and we print a warning message when this happens.
As part of the onSuccess feature, we are moving this logic to Netlify Build (see https://github.com/netlify/buildbot/issues/928). Using Node.js allows us more flexibility, so this might be a good time to improve the underlying logic of this warning message.
Problem
There are several issues with the current logic, which relies on listing the processes then excluding a hard-coded list of processes known to run in our buildbot:
- It relies on a hard-coded list of known processes, which is brittle. Any new process spawned in our buildbot is likely to break that logic.
- It does not work in CLI builds
- It is slow: it spawns almost 10 different processes, serially
- The output of
ps auxis too verbose, making the problem unclear for our users
Solution
I believe the following solution would fix the problems above.
We should list all processes right before the build command and Build plugins are run. We should then do it again right after the build command and Build plugins have completed. We should compute the difference: any process which is then running and was not running before should be reported as a lingering process.
We could also run the above logic both before/after the build command and before/after the build command + Build plugins. Like this, we will know whether the lingering process was created by the build command or by a Build plugin, which we can report to the user, helping them fix the problem.
Related issues
Instead of using Unix utilities, we should also rely on Node.js core APIs and libraries (see #1966).