fix(14-02): parity:upstream writes its sidecar on interrupt or SIGTERM
- the command context had no signal handling, so stopping the proxy killed it before Flush and no sidecar was ever written - a background proxy (SIGINT ignored by the shell) now stops on SIGTERM
This commit is contained in:
@@ -4,8 +4,10 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"git.golem15.com/golem15/summercms/modules/bonfire"
|
||||
@@ -140,6 +142,12 @@ func runParityUpstream(ctx context.Context, in bonfire.Input, out bonfire.Output
|
||||
out.Info(fmt.Sprintf("upstream proxy listening on %s", listen))
|
||||
out.Info(fmt.Sprintf("parity CA certificate: %s", certPath))
|
||||
out.Info(fmt.Sprintf("point the reference backend at it: HTTPS_PROXY=http://%s, curl.cainfo and openssl.cafile=%s", listen, certPath))
|
||||
// The sidecar is written only after the proxy stops, so an interrupt or
|
||||
// SIGTERM must end serving gracefully instead of killing the process. A
|
||||
// shell starts background jobs with SIGINT ignored; NotifyContext
|
||||
// re-enables it.
|
||||
ctx, stop := signal.NotifyContext(ctx, os.Interrupt, syscall.SIGTERM)
|
||||
defer stop()
|
||||
if err := proxy.ListenAndServe(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user