Skip to content
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

Add pidfile support #3235

Closed
otbutz opened this issue Apr 7, 2020 · 9 comments
Closed

Add pidfile support #3235

otbutz opened this issue Apr 7, 2020 · 9 comments
Labels
feature ⚙️ New feature or request
Milestone

Comments

@otbutz
Copy link

otbutz commented Apr 7, 2020

caddy2 seems to lack support for creating a pid file. At least i couldn't find anything in the documentation and both caddy help start / caddy help run didn't list anything related to it.

@mholt
Copy link
Member

mholt commented Apr 7, 2020

What do you need a pid file for?

@otbutz
Copy link
Author

otbutz commented Apr 7, 2020

e.g for easy monit integration:

check process caddy with pidfile /var/run/caddy/caddy.pid

@mholt mholt added the feature ⚙️ New feature or request label Apr 7, 2020
@mholt mholt added this to the 2.x milestone Apr 14, 2020
@francislavoie
Copy link
Member

francislavoie commented Apr 20, 2020

@otbutz I can think of two different ways you could do this with Monit instead of a pid file.

  • Use the remote host check to see if the admin API is alive:
    CHECK HOST caddy ADDRESS localhost:2019
    (if that doesn't work -- I don't use Monit myself -- then CHECK PROGRAM might work, using curl to make a request to http://localhost:2019)
  • Configure Caddy to use a unix socket for the admin endpoint (e.g. admin unix//run/caddy.sock) and then use the file check to see if the admin API is alive:
    CHECK FILE caddy PATH /run/caddy.sock

See https://mmonit.com/monit/documentation/monit.html#Service-checks

While it's definitely possible to add a pidfile option, I'm not convinced it's really necessary here. There are alternate approaches to check if Caddy is alive that fit better with the model Caddy is aiming for.

@otbutz
Copy link
Author

otbutz commented Apr 20, 2020

While i agree that there are plenty of alternatives for monit, this was just an example. If it's simple to add the option it would be nice to keep it, as it was it also provided by caddy v1.

@JACK-THINK
Copy link

e.g for easy monit integration:

check process caddy with pidfile /var/run/caddy/caddy.pid

@mholt @francislavoie

This feature is also what I want.

@mholt mholt closed this as completed in 4df56c7 May 13, 2020
@mholt mholt modified the milestones: 2.x, 2.1 May 13, 2020
@mholt
Copy link
Member

mholt commented May 14, 2020

@otbutz @JACK-THINK Implemented in 4df56c7.

@windware-ono
Copy link

Thanks for adding the --pidfile flag.

However, this can only be specified at command line, which is not so easy to do without modifying the systemd unit file, which is not practical when the unit file gets overridden on package updates.

Can you add --pidfile /var/run/caddy.pid in the systemd unit file from the official package?

@windware-ono
Copy link

@francislavoie, By letting monit monitor a process by PID, it gives you the ability to monitor its CPU, memory and disk IO usage which cannot be done by just monitoring the port or the socket that it listens on.

@mholt
Copy link
Member

mholt commented Mar 8, 2022

@windware-ono Can you please open a new issue? What you're asking for is something different than this issue is, and this issue was closed about 2 years ago.

@caddyserver caddyserver locked as resolved and limited conversation to collaborators Mar 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature ⚙️ New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants
@mholt @francislavoie @windware-ono @JACK-THINK @otbutz and others