-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Feature request: readd reload on USR1 signal #3967
Comments
|
You're aware you can use the |
|
Oh yes (will add it to the list) - but it's still simpler for process managers to send a signal instead of forking a process to run |
|
What process manager are you using here? With systemd, we use https://github.com/caddyserver/dist/blob/master/init/caddy.service#L26 |
|
Yeah; sorry, I'm not sure what the motivation is for a posix-only signal when we already have a more flexible cross-platform solution for this; one that is the same experience for the user on linux too: |
|
I'd like to use make nomad to trigger reload when caddyfile changed via template - using I may use consul template directly to use |
|
Can you pass string arguments that way? Because I'm not sure how that's going to work otherwise. Signals aren't powerful enough. Where will Caddy get the config? Without a |
|
+1 for Nomad usecase. If there's a signal which can be defined to do exactly what |
|
@mr-karan But with what arguments/flags? That's the question. AFAIK you can't pass arguments with signals. |
|
@mholt Not sure if this makes sense but if we hold the config location in memory, we can just reload the existing config with which caddy was running? That's the ideal behaviour of Prior Art: |
|
@mr-karan That doesn't really make sense to me. :)
We can, but reloading the exact same config with no changes has limited utility (like, triggering a manual reload of TLS certs from disk).
This is different, now you want to re-read a file. This is typically the purpose of a config reload, but which file? So does it reload the config in memory or read it from disk? |
We're not reloading the exact config. The config contents changed, the config path didn't change.
same file with which the caddy server was started.
Config is stored on disk. We can just store the config Well this is a typical behavior of hot reloading any process.. please correct if I'm wrong :) |
I guess with most servers that is easy, but with Caddy I'm not sure of a clean way to do it yet. Any way I can think of is pretty hacky. Caddy's config doesn't come from files, it comes through the API. Only the command line interface has any knowledge of files, and only at initial startup. That's why the |
Ah you're right. I totally missed this 🤔 . |
|
Yeah, so that's the main problem: "reload" -- reload what? Do you intend to reload a file even though the config may have changed through the API? (By the way, even configs from files get loaded via the API, the CLI just wraps that up for you.) Or do you intend to reload the currently-running config that was POSTed to the API, without changes (because where would you get the changes from)? Hence the command line arguments; and why, with a signal, it doesn't really make sense since you can't provide args. |
|
Oh, if the server process holds only the final config, not the location of config to look up.. then yes, it has limited utility - only "reevaluating" the existing config. However, I'm wondering we can use |
|
For the nomad use case, I've extended the Caddy container with a bash signal handler that triggers a reload using the Caddyfile which was used when the container was first launched. The code is here (https://github.com/optiz0r/caddy-consul) in case it's useful to anyone else. |
|
As there is a workaround and adding the default file location isn't trivial, I'm closing this issue. Thanks all! |
|
Is it worth adding the sh script workaround to the pre-built docker image, which is hardcoded to use the Caddyfile on startup? (My workaround script puts non-json text to stdout where it gets mixed up with json-formatted output from caddy, so those echos should probably be dropped). It embeds the latest version of tini (to avoid the shell script having to bear the pid1 responsibilities), handles SIGHUP, and passes on SIGTERM, SIGINT, SIGQUIT (but could very easily pass on other signals too, e.g. USR1/2 etc). If you're happy to accept the change, I'll raise it as a PR? |
|
From what I understand, the main argument against keeping/reintroducing the In any case, with |
|
@optiz0r your script work really well, thanks 👍 For Nomad another solution is to use caddy dynamic reverse proxy with consul service SRV record so you don't need to reload caddy config but it requires more configuration to setup Consul DNS forwarding https://learn.hashicorp.com/tutorials/consul/dns-forwarding ... |
|
For the Nomad use case, we can make use of the (Sorry for commenting on an old issue; I just thought I might drop this hint for future troubleshooters.) |

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

Caddy < 2 had reload on USR1 signal (#107 / 41c4484), but it was dropped in v2 (#2242) (see also discussion)
Although there are other ways to reload the config (using
--watchoption, or makingPOST /loadrequest) but it would be nice to have the feature back so that ops can determine when to apply the changes without installing http client.(edit: also
caddy reloadis there, but it requires passing config again)The text was updated successfully, but these errors were encountered: