aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMatthew Holt <[email protected]>2023-04-03 11:57:16 -0600
committerMatthew Holt <[email protected]>2023-04-03 11:57:16 -0600
commit508cf2aa228c42a0d1b9a0dbc4351a876e51b5d9 (patch)
treea6dc8e3c90aaac33739651b19d3e20f423aab4f6
parentf9bd2d3e9229d8c12f8c2ad470ec62750198cdd8 (diff)
downloadcaddy-508cf2aa228c42a0d1b9a0dbc4351a876e51b5d9.tar.gz
caddy-508cf2aa228c42a0d1b9a0dbc4351a876e51b5d9.zip
cmd: Create pidfile before config load (close #5477)
-rw-r--r--cmd/commandfuncs.go20
1 files changed, 10 insertions, 10 deletions
diff --git a/cmd/commandfuncs.go b/cmd/commandfuncs.go
index cc5666bb1..77a4cdf4a 100644
--- a/cmd/commandfuncs.go
+++ b/cmd/commandfuncs.go
@@ -208,6 +208,16 @@ func cmdRun(fl Flags) (int, error) {
}
}
+ // create pidfile now, in case loading config takes a while (issue #5477)
+ if runCmdPidfileFlag != "" {
+ err := caddy.PIDFile(runCmdPidfileFlag)
+ if err != nil {
+ caddy.Log().Error("unable to write PID file",
+ zap.String("pidfile", runCmdPidfileFlag),
+ zap.Error(err))
+ }
+ }
+
// run the initial config
err = caddy.Load(config, true)
if err != nil {
@@ -242,16 +252,6 @@ func cmdRun(fl Flags) (int, error) {
go watchConfigFile(configFile, runCmdConfigAdapterFlag)
}
- // create pidfile
- if runCmdPidfileFlag != "" {
- err := caddy.PIDFile(runCmdPidfileFlag)
- if err != nil {
- caddy.Log().Error("unable to write PID file",
- zap.String("pidfile", runCmdPidfileFlag),
- zap.Error(err))
- }
- }
-
// warn if the environment does not provide enough information about the disk
hasXDG := os.Getenv("XDG_DATA_HOME") != "" &&
os.Getenv("XDG_CONFIG_HOME") != "" &&