Can't start Caddy with systemd service file


(no name) #1

Hello. I’m trying to run Caddy with the “official” systemd.service but so far I haven’t had any luck.
I used the guide on GitHub but the service fails to start and running systemctl status caddy.service gives:

● caddy.service - Caddy HTTP/2 web server
   Loaded: loaded (/etc/systemd/system/caddy.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Thu 2018-03-08 23:13:20 CET; 4min 5s ago
     Docs: https://caddyserver.com/docs
  Process: 16306 ExecStart=/usr/local/bin/caddy -log stdout -agree=true -conf=/etc/caddy/Caddyfile -root=/var/tmp (code=exited, status=1/FAILURE)
 Main PID: 16306 (code=exited, status=1/FAILURE)

Mar 08 23:13:11 t110 systemd[1]: Started Caddy HTTP/2 web server.
Mar 08 23:13:17 t110 caddy[16306]: Activating privacy features... 2018/03/08 23:13:17 [INFO][test.page] acme: Obtaining bundled SAN certificate
Mar 08 23:13:18 t110 caddy[16306]: 2018/03/08 23:13:18 [INFO][test.page] AuthURL: https://acme-v01.api.letsencrypt.org/acme/authz/8KHdBW0tvJFlGbMVc_B7OhngWbA7eLAlf6fSIq25VXY
Mar 08 23:13:18 t110 caddy[16306]: 2018/03/08 23:13:18 [INFO][test.page] acme: Trying to solve HTTP-01
Mar 08 23:13:20 t110 systemd[1]: caddy.service: Main process exited, code=exited, status=1/FAILURE
Mar 08 23:13:20 t110 systemd[1]: caddy.service: Unit entered failed state.
Mar 08 23:13:20 t110 systemd[1]: caddy.service: Failed with result 'exit-code'.

This is my Caddyfile:

test.page {
  root /var/www/test/
  log stdout
  errors stderr
  gzip
}

I don’t see any particular error reported by systemctl status or journalctl, Caddy seems to just die, and that is strange.
This is on a Dell PowerEdge T110 machine running fresh Debian 9 with the latest updates and systemd v232.


(Matthew Fay) #2

Hi @plumbe0, welcome to the Caddy community.

Can you give us your caddy -version? And what happens if you run Caddy manually from command line with the same arguments as your unit file?

I doubt that the domain test.page would succeed a domain validation, but you should at least receive an error saying as much.


(no name) #3

Caddy version is 0.10.11
Indeed, launching caddy from the cli helped debugging the issue: the domain could not be validated. I wonder why it didn’t appear in systemd logs. Thanks for your help.


(Mark) #4

Use journalctl -xef -u caddy.service to follow the logs.

systemctl status … will display an excerpt.

If the error is displayed when starting Caddyserver from a console, but is not shown in the logs if an init daemon such as systemd is used (which logs stdout and stderr), then Caddyserver’s authors have forgotten to Flush stdout and/or stderr before exiting. :wink:
(cc @matt)


(system) #5

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