-
Notifications
You must be signed in to change notification settings - Fork 129
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
Non-deterministic restart order of daemons #94
Comments
Hi there. Thanks for the complete problem description. It would be great to have a deterministic order here, but there's a problem: there's no consistent way to tell when a daemon has completely responded to a signal. This is super-dependent on the specific behaviour of the daemon in question. In your particular case, what might work would be to trigger the devd reload when the persistent assets are changed by myapp, rather than when the Go source files change. I'll keep this issue open while I think about this. |
what's wrong with a wait command?
|
Yep. Just tested it with mine, works great:
|
Hi @cortesi, thanks for modd and devd. Both are fantastic productivity tools in my opinion.
I am having trouble with a workflow in modd and I'm not totally sure that it's not a user error.
Summary
It seems the restart order of daemons is currently non-deterministic. They do receive their signals in order but if a signal leads to a restart this might lead to a race condition.
Explanation
I have a web application that serves it's own assets and I want to use devd to enable live reloading during development.
Consider the following
modd.conf
:myapp
renders templates and serves assets. Devd is only used for live-reloading which works fine for assets and templates.But here is what happens when I change a go file:
As you can see, devd triggers a reload before my application daemon restarts. This leads to my browser showing a blank page until I manually refresh.
Looking at the code in
daemon.go
I think I figured out what is happening.func (d *Daemon) Run()
that keeps restarting the daemon unless it was stopped.The race condition is between the restart loop of the DaemonPen and the run loop of the Daemon. If the run loop restarts my daemon before the restart loop of the DaemonPen restarts the next daemon, everything is fine. Which never happened for me btw.
Towards a solution
The problem would vanish if modd waited for each daemon to process the signal and/or restart before proceeding with the next daemon. However I am aware that signals are asynchronous, so I think a solution will not be that simple.
I'm willing to contribute code but wanted to hear what you think before starting to work on a solution.
The text was updated successfully, but these errors were encountered: