sg: ungraceful exit does not kill jaeger
Created by: camdencheek
When sg
exits ungracefully, either due to a failed build or a critical failure (panic), it does not kill the jaeger subprocess, so the next time it is started, it fails until I run pkill jaeger
because the port is already taken.
This seems to be because CommandContext
sends a kill signal to the process it created, but the created process is the bash parent, which disowns the child jaeger process when killed.
It's unclear to me why jaeger seems to be running as a child of a bash process when other binaries, like gitserver, do not. All subprocesses seem to be started with "bash", "-c", cmd
in startCmd
. Maybe it's because the jaeger cmd redirects stderr to stdout, so bash can't just exec in-place, and instead forks and stays alive to merge stdout/stderr?
❯ pstree | grep jaeger -C1
| | |-+- 96456 ccheek bash -c .bin/jaeger-all-in-one-${JAEGER_VERSION}-$(go env GOOS)-$(go env GOARCH) --log-level ${JAEGER_LOG_LEVEL} >> "${JAEGER_LOGS}"/jaeger.log 2>&1\012
| | | \--- 96461 ccheek .bin/jaeger-all-in-one-1.18.1-darwin-amd64 --log-level info
❯ pstree | grep gitserver -C1
| | \-+= 96394 ccheek sg start
| | |-+- 96782 ccheek .bin/gitserver