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

Restart the program if it fails #72

Open
mitar opened this issue Feb 24, 2022 · 2 comments
Open

Restart the program if it fails #72

mitar opened this issue Feb 24, 2022 · 2 comments

Comments

@mitar
Copy link

mitar commented Feb 24, 2022

Sometimes a running program fails because of the panic. Because CompileDaemon keeps running it is hard to notice that (except for the panic stack trace). I think it would be best if CompileDaemon would just restart the program, with some message (like, "program terminated, restarting"). Probably as opt-in CLI flag.

@mitar mitar changed the title Restart the program if if fails Restart the program if it fails Feb 24, 2022
@githubnemo
Copy link
Owner

If you need more sophisticated job management I would recommend using a shell script that launches the executable and watches for the actual program. A very simple one would be something like

#!/bin/bash

while true; do
    ./my_go_executable "$@"
    sleep 5 # avoid flooding the system with crashing applications
done

I don't think this is a job for CompileDaemon :)

ederuiter added a commit to thisisdevelopment/CompileDaemon that referenced this issue Jul 9, 2022
See https://medium.com/@felixge/killing-a-child-process-and-all-of-its-children-in-go-54079af9477 for a detailed explanation of how this works. For now this only implemented for posix and these changes should have no effect on windows.
This fixes githubnemo#65 and makes the script in githubnemo#72 work (without this fix the script would be terminated on re-compile, but the go executable would continue to run, potentially causing issues with used resources like files and sockets)
@asalkeld
Copy link

asalkeld commented Aug 4, 2022

I have a commit on a fork that does this: asalkeld@238f1e6
If you are interested, I'll happily make a PR.

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

3 participants