Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bugfix: switch to unix socket for embedded caddy adminapi
This fixes a bug first reported by Albert Gimeno here: https://twitter.com/gimenete/status/1680966368626192389?s=20 > For my regular job I realized we are using caddy as well internally > and I can't have both projects running at the same time. localias says > that the localias daemon is already running but it's actually the > embedded caddy in another app. I was able to reproduce this problem: 1. `localias daemon start` — binds localhost:2019 to localias's embedded caddy admin server 2. `caddy start` — binds localhost:2019 to the caddy admin server 3. `localias daemon stop` or `localias daemon reload` — requests are handled by caddy, not localias's embedded caddy. This breaks localias's expected behavior and interferes with the other caddy server, Not Good. This PR fixes the problem by using a unix domain socket to communicate with the embedded caddy server. This socket is stored in the localias state directory, just like the rest of the server's config data. As reported in caddyserver/caddy#2749 this is well-supported by Caddy, which made implementing this very easy — just needed to switch `admin localhost:2019` to `admin "unix//absolute/path/to/socket"`. The fix uncovered a minor problem in the way I was determining the Caddy server API address but that was easily fixed by reading the Caddy docs. Have I mentioned how much I love Caddy? Only tested on macOS, hopefully works in other environments.
- Loading branch information