Everything works, I installed via homebrew and now I can run caddy. Nice. But I want it to run in the background, even after mac has restarted. I thought this is what caddy run is for. But it’s not.
So what do I have to do to make caddy restart the service on start up. With my other homebrew installed services, like postgres or mongodb, they automatically restart when my system restarts.
And with that, if i have to do anything globally, where would I put my global Caddy file? Or could I provide it somehow with caddy start -config ~/my/custom/path?
Thanks for any help guys!
PS: Yes I looked at this old post, but that does not seem to work anymore, I tried it: Run caddy on macOS startup
(Interesting; I thought the homebrew formula did this for you. Guess not.)
The launchd file from Caddy v1 can be found in our repo on the v1 branch here:
You’ll need to update that to work for Caddy v2, but the overall launchd steps should be similar (unless Apple has changed how it works in recent Mac versions – I don’t dev on a Mac anymore so I dunno).
Once someone figures it out, would be a good addition to our community wiki here!
Indeed brew services start caddy (note the s), starts caddy. But regarding the Caddyfile, there is nothing in /usr/local/etc/Caddyfile. I created the etc/ folder and added a Caddyfile. But it is not being picked up automatically. When I do sth like this instead: brew services start caddy --file ~/my/custom/Caddyfile I get this ouput:
Bootstrap failed: 5: Input/output error
Try re-running the command as root for richer errors.
Error: Failure while executing; `/bin/launchctl bootstrap gui/501 /Users/phil/Library/LaunchAgents/homebrew.mxcl.caddy.plist` exited with 5.