You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: risefront.go
+14-10Lines changed: 14 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ import (
24
24
25
25
// Storing global configurations for use in Restart functions
26
26
var (
27
-
globalConfigConfig
27
+
globalConfig*Config
28
28
)
29
29
30
30
// Dialer is used for the child-parent communication.
@@ -37,12 +37,12 @@ type Config struct {
37
37
Addresses []string// Addresses to listen to.
38
38
Runfunc([]net.Listener) error// Handle the connections. All open connections should be properly closed before returning (srv.Shutdown for http.Server for instance).
39
39
40
-
Namestring// Name of the socket file
41
-
DialerDialer// Dialer for child-parent communication. Let empty for default dialer (PrefixDialer{}).
42
-
Networkstring// "tcp" (default if empty), "tcp4", "tcp6", "unix" or "unixpacket"
43
-
ErrorHandlerfunc(kindstring, errerror) // Where errors should be logged (print to stderr by default)
44
-
RestartSignal os.Signal// Signal to trigger a restart
45
-
NoRestartbool// Disables all restarts
40
+
Namestring// Name of the socket file
41
+
DialerDialer// Dialer for child-parent communication. Let empty for default dialer (PrefixDialer{}).
42
+
Networkstring// "tcp" (default if empty), "tcp4", "tcp6", "unix" or "unixpacket"
43
+
ErrorHandlerfunc(kindstring, errerror) // Where errors should be logged (print to stderr by default)
44
+
RestartSignal os.Signal// Signal to trigger a restart
45
+
NoRestartbool// Disables all restarts
46
46
LogHandlerfunc(loglevelLogLevel, kindstring, args...interface{}) // Where debug messages should be logged
47
47
48
48
_struct{} // to later add fields without break compatibility.
@@ -59,12 +59,12 @@ type Config struct {
59
59
// The parent will live as long as the context lives.
60
60
// The child will live as long as the parent is alive and no other child has been started.
61
61
funcNew(ctx context.Context, cfgConfig) error {
62
+
// Save the global configuration for use in Restart
63
+
globalConfig=&cfg
64
+
62
65
// Save the original arguments to pass to the child process
63
66
cfg.args=os.Args
64
67
65
-
// Save the global configuration for use in Restart
66
-
globalConfig=cfg
67
-
68
68
// First, try to get file descriptors from overseer
69
69
iflisteners, err:=FromOverseerFDs(); err!=nil {
70
70
returnerr
@@ -457,6 +457,10 @@ type childRequest struct {
457
457
458
458
// Restart creates a child process instead of sending a signal
459
459
funcRestart() {
460
+
ifglobalConfig==nil {
461
+
panic("globalConfig is nil, Restart() should only be called from within a child process")
0 commit comments