I had no idea, so I went looking and found nothing useful so I made some adjustments to the service file (step 2c above) to direct stdout
and stderr
to a file. I restarted the jail and now can’t make Caddy fall over!
It seems that when Caddy started in the background, such as when a jail starts or restarts, there was nowhere for stdout and stderr to go so Caddy would cough, splutter and die. It wasn’t an issue when Caddy was started manually as output was directed to the terminal. By directing Caddy output to a file when the jail restarts, Caddy now happily hums along blissfully unaware that there is any issue at all!
@francislavoie Thank you for that genius tip! I wasn’t looking forward to using the expanded form of php_fastcgi.
I’ll provide some feedback to the FreeBSD Caddy port maintainer to suggest an amendment to the service initialisation file.
Afterthought: My logic may not be completely bulletproof. It doesn’t explain why output redirection was not necessary for step 5 above. Any ideas? Is there still an issue lurking somewhere in the shadows?