Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gracefully handle backgrounded processes #143

Closed
mculp opened this issue Jan 3, 2023 · 2 comments
Closed

Gracefully handle backgrounded processes #143

mculp opened this issue Jan 3, 2023 · 2 comments

Comments

@mculp
Copy link

mculp commented Jan 3, 2023

Kinda similar to some of the other issues on here. rubocop --start-server always runs daemonized, which kills the other processes. In this case, there's no signal to trap, since it's just spawning another process.

Hopefully the issue will be remedied soon on their side soon, as they have a pull request open: rubocop/rubocop#11319

But I think a lot of folks would benefit from some type of solution for this -- whether it's before/after hooks, process order, process dependencies, or something else.

My workaround:

OVERMIND_CAN_DIE=rubocop rubocop --start-server

This isn't a great workaround, because the server continues running even after Overmind has shutdown.

image

But you can see the rubocop server running:

image

Here, you can see all processes running:
(I guess it's a separate issue, but there are two of each of them)
image

After overmind stop:
image

@DarthSim
Copy link
Owner

Unfortunately, I don't see any way to fix this on the Overmind's level. When daemonizing, the process launches another process within another process group. Thus Overmind can't get the new process's PID and can't monitor its status.

As a dirty bypass:

rubocop: trap 'rubocop --stop-server' EXIT > /dev/null; rubocop --start-server && ping localhost > /dev/null

trap 'rubocop --stop-server' EXIT > /dev/null sets the trap on exit so rubocop --stop-server will be executed when the script exits.
ping localhost > /dev/null makes script keeping running after rubocop --stop-server exits.

@mculp
Copy link
Author

mculp commented Jan 25, 2023

agh! That ping trick worked! But that is definitely a dirty, dirty bypass :)

Thank you.

@mculp mculp closed this as completed Jan 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants