Caddy: RFE: implement support for systemd's sd_notify

Created on 15 Apr 2016  路  8Comments  路  Source: caddyserver/caddy

I'd like to see support for systemd's sd_notify in Caddy.

Advantages of implementing this:

  • Caddy can properly signal to systemd once it's actually ready. Currently systemd simply has to assume it is ready to serve requests once the process is started while in reality Caddy might take a little longer than that to establish all listening sockets, deal with ACME, etc.
  • Caddy can provide an informational output to systemd's service status, similar to what Apache httpd does (Status: line):

httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled) Active: active (running) since Sat 2016-04-04 8:48:50 UTC; 1 weeks 3 days ago Process: 21400 ExecReload=/usr/sbin/httpd $OPTIONS -k graceful (code=exited, status=0/SUCCESS) Main PID: 390 (httpd) Status: "Total requests: 34; Current requests/sec: 4; Current traffic: 7 B/sec" CGroup: /system.slice/httpd.service 鈹溾攢 390 /usr/sbin/httpd -DFOREGROUND 鈹溾攢15379 /usr/sbin/httpd -DFOREGROUND 鈹溾攢15858 /usr/sbin/httpd -DFOREGROUND

The basic sd_notify implementation is rather trivial and straight-forward (see references below), but I have no idea where to hook this up within Caddy and how to go about gathering informative data for the status display, so I'm filing this as an RFE for now.

References:

feature request

Most helpful comment

I am with you on this one and started some work going in that direction:

https://github.com/mholt/caddy/compare/master...wmark:systemd-sockets

Asking /@all: What other _init_ daemons do support fine-grained status notifications? Is it worth changing a TTY title bar, too, if Caddy were the foreground process?

All 8 comments

I am with you on this one and started some work going in that direction:

https://github.com/mholt/caddy/compare/master...wmark:systemd-sockets

Asking /@all: What other _init_ daemons do support fine-grained status notifications? Is it worth changing a TTY title bar, too, if Caddy were the foreground process?

I'd like to classify this as being more important than 禄nice to have芦:

On slow systems Caddy is shown as 禄ready芦 but not serving any connections yet. For example, on my arm7 it takes a few seconds to one minute, and I had no idea what was going on until learning that Caddy was indeed loading and parsing certificates.

That said, if the terminal is a TTY then yes, changing the title bar helps a lot.

Please no messing with TTY title bars.

What about making TTY-manipulation configurable?

I will implement something that accepts plugins, add systemd no it, and we will go from there.

My point-in-time readiness estimation is mid of this week for reviews.

@wmark while you're at it, it might be a relatively low-hanging fruit to implement support for systemd's watchdog functionality via sd_notify() in Caddy's main loop.

See also:

Sending keep-alive signals in a goroutine will not tell us if any sockets (like, listening sockets) dropped out, if we ran out of file descriptors, or if a thread had been killed by the system.

A proper watchdog implementation would need to cycle over all sockets, ingress and egress, and see if connections get responses.

The _watchdog_ feature is not covered by my PR.

I am closing this in favour of #777. If you have other ideas, please open an issue if and when #777 is in.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kilpatty picture kilpatty  路  3Comments

aeroxy picture aeroxy  路  3Comments

dafanasiev picture dafanasiev  路  3Comments

SteffenDE picture SteffenDE  路  3Comments

PhilmacFLy picture PhilmacFLy  路  3Comments