Closed Rambatino closed 3 years ago
Command: PORT=3000 CompileDaemon -command="go run main.go"
Both graceful and not result in the same output.
If I had to venture a guess then it is probably due to the socket not being closed fast enough (still waiting for an ACK from some connection, for example) and is still in CLOSE_WAIT
state. You can verify this by running netstat -ton | grep CLOSE_WAIT
in parallel.
There is no real fix for this other than terminating the connections beforehand (or not keeping them open at first) or to wait some time before the command the next time (in a pickle you could create a shell script that runs sleep 1 && go run main.go
, for example).
So I've found the reason, it's because it's not actually killing the child processes.
Even if I do the second thing in a bash script, it doesn't kill the server pid it kills the parent process pid. See: https://stackoverflow.com/questions/24982845/process-kill-on-child-processes
When I re-execute the binary it works and kills and restarts it properly (although the code obviously doesn't change).
I would argue that this library should kill the child processes too.
ahh my bad there's a build command, so that does work! Thanks!
I'm obviously missing something, but I can't seem to catch the SIGTERM signal and gracefully terminate the running server.
Results in: