Checking Caddy Restart

Hi everyone, am trying to learn how to restart Caddy whenever I change the Caddyfile. I read the following link

From what I could see am guessing I would send the USR1 signal to the process. I tried the following ways:

kill -USR1 1234
killall -s USR1 caddy
pkill -USR1 caddy

But I believe none of them worked, the reason is that I sabotaged the Caddyfile in order to check if it would fail when during the restart. I added a number on the url of the site, so instead of saying it says 1 (Prefixed with the 1) but after sending the signals above it did not fail. It simply kept on going.

Am comparing this to literally killing Caddy and then manually starting it again with caddy &

When I manually do this, it fails correctly saying that there is a 1 in the url. But when I send the signals it does not. Now my question is:

  1. Is this a bug?
  2. Am I sending the signals in a wrong way?
  3. Is there a parameter to restart Caddy (eg: caddy --restart)
  4. Are the signals sent actually working but caddy reloads the script and fixes the configuration?

Basically, what is going on here, am I wrong or am I missing something?

Caddy checks the configuration when it gets a USR1 signal, so if the config is corrupt, it’ll keep using the old one. To test it, you’ll have to change the config to something valid, but different.

Jeez, thank you Cylindric. Am used to dumb web servers, did not know Caddy had that behavior. So just to confirm, the commands used to send the signal are correctly working, it’s just that Caddy sticks with the config that works.

Yep I think so. I just tested it, and interestingly Caddy doesn’t create a log entry for when a reload happens. I really think it should! Maybe @matt or someone with knowledge can confirm that it doesn’t log?

It definitely does log that a USR1 was received and is reloading.

[INFO] SIGUSR1: Reloading

If there’s an error, you’ll see:

[ERROR] SIGUSR1: <error>

lol ignore me then, I’m an idiot. I could have sworn I was tailing that log file…

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.