endless icon indicating copy to clipboard operation
endless copied to clipboard

fork() should use cmd.Run() rather than cmd.Start()

Open EricHouang opened this issue 4 years ago • 1 comments

func (c *Cmd) Run() error { if err := c.Start(); err != nil { return err } return c.Wait() // if execute the command fails,return error } I use endless in my project. In a production environment, we need to modify the configuration file frequently, and then restart the program for the new configuration to take effect. But the configuration file often has syntax errors, making the program unable to restart successfully. We need to modify the configuration again and restart again, but endless output "Fork err: Another process already forked. Ignoring this one."

EricHouang avatar Mar 13 '20 13:03 EricHouang

In my scenario, I use'./app -s restart' to restart server, when app get the arg of '-s restart', it's will do

  1. check config file(include format)
  2. get PIDFile in cofig file
  3. When the process pointed to by pid is running, send SIGHUP to it
  • so I think u should check config file before send restart signal
  • about fork() use the cmd.Start(), I use it to run a deamon process, so the cmd.Run() con't return, until daemon process exit

This is just my suggestion, I hope it will be useful to you

SURA907 avatar Jul 03 '20 04:07 SURA907