-
-
Notifications
You must be signed in to change notification settings - Fork 256
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
fix - graceful shutdown #1242
fix - graceful shutdown #1242
Conversation
As a sidenote: I'm still not sure why calling |
|
||
// attempt a graceful shutdown if we are not running tests | ||
if flag.Lookup("test.v") == nil { | ||
frankenphp.Shutdown() |
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.
This cannot work because in case of reload, Caddy starts the new module before stopping the old one.
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.
Oh I think I get it now. There's an experimental caddy.Exiting() api that we could maybe use instead.
Is there also a way to reload Caddy outside of tests? Running curl "http://localhost:2019/load"
via the admin API also doesn't work on main.
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.
Nvm I realized you have to actually patch the whole config for a reload
curl "http://localhost:2019/config/apps/frankenphp" -X PATCH --header "Content-Type: application/json" -d '{"workers"
:[{"file_name":"/go/src/app/testdata/index.php","watch":["./**/*.{php,yaml,yml,twig,env}"]}]}' -H "Cache-Control: must-revalidate"
This works now with the Exiting()
check if you're fine with using an experimental api. Otherwise I'll close this PR.
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.
You can use --force
if you're using caddy reload
or equivalent, which is the same as passing the Cache-Control: must-revalidate
header in the API to reload even if the config text has not changed.
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.
LGTM!
Could you please rebase? |
# Conflicts: # frankenphp.go
Thanks! |
This PR fixes #1226 by calling
frankenphp.Shutdown()
onCaddy's Shutdown()
.I also went ahead and replaced the
CaddyUsagePoo
l by a global boolean. It's probably simpler to just haveShutdown()
do nothing if FrankenPHP is not running (unless I'm missing something).