sourcegraph/cmd/github-proxy/shared
Chris Warwick 33cac9fae1
App - Fix shutdown of postgres when terminating (#52463)
Addresses https://github.com/sourcegraph/sourcegraph/issues/52420

Previously when App shut down it was leaving behind postgres processes
thats caused issues due to the socket from the previous instance
remaining. This is manifest to the user as a app with a blank screen
that wouldn't launch.

There were several issues

1. The github proxy was calling `os.Exit` on the first shutdown signal
received. This is an issue for app because all services are running in
the same parent process it would terminate the app before any other
services or postgres could properly close.
2. Once the `os.Exit` issue was resolved the single binary would never
terminate because it was paused on an empty select. This replaces the
empty select with a 2nd wait group that waits for the termination of
each service that was started. The app will exit now but leaves a race
condition on shutdown of the services and postgres.
3. To resolve the race condition I removed postgres from being monitored
as a background process and instead return a cleanup function from
`Init` so that balance can be restored. Init is responsible for starting
postgres before any service and now it can inform the caller how to
clean up anything it needs to.
2023-05-26 09:34:27 -04:00
..
BUILD.bazel bazel: fix buf files (#49444) 2023-03-15 20:21:38 +00:00
service.go Sourcegraph App (single-binary branch) (#46547) 2023-01-19 17:35:39 -07:00
shared_test.go extract github-proxy main to shared package for external invocation (#45113) (#45868) 2022-12-20 20:56:39 -08:00
shared.go App - Fix shutdown of postgres when terminating (#52463) 2023-05-26 09:34:27 -04:00