caddy icon indicating copy to clipboard operation
caddy copied to clipboard

Add startup event

Open AndreKR opened this issue 11 months ago • 2 comments

(Caddy 1 had an on startup directive that was very convenient to start php-fpm. The new process would get marked as a child process and when I clicked the close button it the child process would get killed.)

Caddy 2 has { events { on ... exec ... } } but unfortunately there is no startup event.

It should be relatively easy to add such an event to Caddy itself? I tried implementing it as a plugin, but it is surprisingly difficult to make a plugin that has no config but still gets caddy.Context, which is needed to get the events app and fire the event.

AndreKR avatar Feb 12 '25 00:02 AndreKR

What's the use case? Normally it's not useful to know when the process started because you are typically the one who starts it.

mholt avatar Mar 03 '25 20:03 mholt

I would bind an exec handler to it, which would then start php-fpm.

That way I just need to double-click Caddy to start both Caddy and PHP and, more importantly, php-fpm will be a child process of Caddy, so when I click the X to close the Caddy window, it will kill the PHP process as well.

AndreKR avatar Mar 03 '25 21:03 AndreKR