Caddy server reload after update CaddyFile

(Job Noam) #1
  • explain what you are trying to do,
    I want to reload CaddyServer after changing CaddyFile without downtime.
  • show what you have already tried,
    I saw that I can do that with this 2 options right now:
  1. pkill -USR1 caddy
  2. ps -C caddy
    1392 pts/0 00:00:00 caddy
    kill -s USR1 1392

And I don’t to know if this two options if right for me and will not make any downtime. And also if there is other options I need to know about?

(Matthew Fay) #2

Both those options will trigger a graceful reload of Caddy.

You may be interested in -pidfile, a command-line flag for Caddy that will tell it to write its process ID to the file you specify. You can then read that file to generate a kill command, like kill -s USR1 $(cat /path/to/pidfile).

(Job Noam) #3

So they both do that without downtime, right?

(Matthew Fay) #4

Correct, a graceful reload of Caddy has no downtime.

If the reload fails, Caddy will continue serving sites using the old configuration, with no interruption to service.

(Mark) #5

In case your distro comes with systemd you might as well use its path unit files. (Adjust the following paths!)

# /etc/systemd/system/caddy-reload.path
Description=Trigger a reload of Caddy on changes to its config file


# /etc/systemd/system/caddy-reload.service
Description=Reload Caddy

; ExecStart=/usr/bin/sleep 0.1s
ExecStart=/bin/systemctl try-reload-or-restart caddy.service

(system) #6

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