Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 13, 04:15 UTC
cmd: Create pidfile before config load (close #5477)
Matthew Holt committed
Apr 3, 2023 at 11:57 UTC
508cf2aa228c42a0d1b9a0dbc4351a876e51b5d9
1 file changed
+10
-10
cmd/commandfuncs.go
+10
-10
@@ -208,6 +208,16 @@ func cmdRun(fl Flags) (int, error) {
208
}
209
}
210
211
+ // create pidfile now, in case loading config takes a while (issue #5477)
212
+ if runCmdPidfileFlag != "" {
213
+ err := caddy.PIDFile(runCmdPidfileFlag)
214
+ if err != nil {
215
+ caddy.Log().Error("unable to write PID file",
216
+ zap.String("pidfile", runCmdPidfileFlag),
217
+ zap.Error(err))
218
+ }
219
+ }
220
+
221
// run the initial config
222
err = caddy.Load(config, true)
223
if err != nil {
@@ -242,16 +252,6 @@ func cmdRun(fl Flags) (int, error) {
252
go watchConfigFile(configFile, runCmdConfigAdapterFlag)
253
}
254
245
- // create pidfile
246
- if runCmdPidfileFlag != "" {
247
- err := caddy.PIDFile(runCmdPidfileFlag)
248
- if err != nil {
249
- caddy.Log().Error("unable to write PID file",
250
- zap.String("pidfile", runCmdPidfileFlag),
251
- zap.Error(err))
252
- }
253
- }
254
-
255
// warn if the environment does not provide enough information about the disk
256
hasXDG := os.Getenv("XDG_DATA_HOME") != "" &&
257
os.Getenv("XDG_CONFIG_HOME") != "" &&