mirror of
https://github.com/niusmallnan/steve.git
synced 2025-04-27 19:06:05 +00:00
Fix restart of steve aggregation
This commit is contained in:
parent
bcbcef36b3
commit
e70fca2a42
@ -60,12 +60,24 @@ func ListenAndServe(ctx context.Context, url string, caCert []byte, token string
|
||||
func serve(ctx context.Context, dialer websocket.Dialer, url string, headers http.Header, handler http.Handler) error {
|
||||
url = strings.Replace(url, "http://", "ws://", 1)
|
||||
url = strings.Replace(url, "https://", "wss://", 1)
|
||||
conn, _, err := dialer.DialContext(ctx, url, headers)
|
||||
|
||||
// ensure we clean up everything on exit
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
defer cancel()
|
||||
|
||||
dialCtx, dialCancel := context.WithTimeout(ctx, 5*time.Second)
|
||||
defer dialCancel()
|
||||
conn, _, err := dialer.DialContext(dialCtx, url, headers)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
go func() {
|
||||
<-ctx.Done()
|
||||
conn.Close()
|
||||
}()
|
||||
|
||||
listener := NewListener("steve")
|
||||
server := http.Server{
|
||||
Handler: handler,
|
||||
|
@ -85,7 +85,7 @@ func (h *handler) shouldRestart(secret *corev1.Secret) (string, []byte, string,
|
||||
|
||||
if h.url != url ||
|
||||
h.token != token ||
|
||||
bytes.Equal(h.caCert, caCert) {
|
||||
!bytes.Equal(h.caCert, caCert) {
|
||||
return url, caCert, token, true, nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user