Switch to program directory when running as Windows service #5115
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As noted in #5106, when installing Caddy as a native Windows service (For reference, the PowerShell command for that is
New-Service -Name caddy -BinaryPathName "C:\caddy\caddy.exe run"
), caddy starts up inC:\WINDOWS\SYSTEM32
- I think this is a bad idea for multiple reasons:Caddyfile
intosystem32
(well, you technically can, but that sound like a bad idea all around) and as an alternative, you have to run caddy with a much longer command line (LikeNew-Service -Name caddy -BinaryPathName "C:\caddy\caddy.exe run --config C:\caddy\Caddyfile"
Caddyfile
, those will be relative to thesystem32
directory, which will lead to hard-to-debug problems...This is a "prototype" of a simple fix: When we are running as a Windows service, try to chdir into the caddy program directory - It works for me[tm] in a Windows 10 VM...