-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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 gracefully with in-process restart #807
Conversation
) | ||
|
||
// File descriptors for in-process restart | ||
var restartFds map[string]*os.File = make(map[string]*os.File) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any race condition here? (Edit: On second thought, probably not, since Start()
gets called in same goroutine as the signal trap. I'll double-check anyway.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No race condition.
Follow-up though, could we revise this line to remove the lint notice:
caddy\restartinproc.go:9:16: should omit type map[string]*os.File from declaration of var restartFds; it will be inferred from the right-hand side
So, change to:
var restartFds = make(map[string]*os.File)
Woah. I have yet to try this, but if this works and is free of races, let's drop the "new process" restart altogether and just use this (and drop the |
This works wonderfully. The race detector does not detect any races. @tpng I really love this. Going to merge in after I or others have a chance to review more closely! |
Wait, does this also work on Windows? |
Actually I don't know how to trigger a Caddy restart on Windows since the USR1 is only available on POSIX system. If there are other conditions to trigger a restart on Windows I can test it to see if it works. |
It seems Go doesn't implement the |
For triggering a restart on Windows, I was just thinking of a test that calls the Restart() function. But since FileListener isn't implemented on Windows (I knew that once, but since forgot), we will still have the regular "Windows" restart that we have now. But all other restarts can be switched to this. 👍 |
OK, so I need to update the pull request to do the following? |
What if the "windows restart" was the current improc one and we note in On Friday, May 6, 2016, Benny Ng notifications@github.com wrote:
|
Yes, Windows will use the current inproc one. |
0caab31
to
088930e
Compare
088930e
to
fbb72ab
Compare
@@ -322,17 +292,6 @@ func Wait() { | |||
// are no other errors, this function always returns at least the | |||
// default Caddyfile. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have this godoc comment updated too, removing the part about piping in as part of a restart.
Benny, this is looking beautiful. I think I'm gonna cry. 😂 |
fbb72ab
to
9705f34
Compare
Great work @tpng, thank you!! |
This patch allows Caddy to restart in-process gracefully without the
-restart=inproc
flag, replacing the current default Restart on POSIX system.