File tree Expand file tree Collapse file tree 3 files changed +2
-74
lines changed Expand file tree Collapse file tree 3 files changed +2
-74
lines changed Original file line number Diff line number Diff line change @@ -17,29 +17,7 @@ limitations under the License.
17
17
package signals
18
18
19
19
import (
20
- "context"
21
- "os"
22
- "os/signal"
20
+ apiserver "k8s.io/apiserver/pkg/server"
23
21
)
24
22
25
- var onlyOneSignalHandler = make (chan struct {})
26
-
27
- // SetupSignalHandler registers for SIGTERM and SIGINT. A context is returned
28
- // which is canceled on one of these signals. If a second signal is caught, the program
29
- // is terminated with exit code 1.
30
- func SetupSignalHandler () context.Context {
31
- close (onlyOneSignalHandler ) // panics when called twice
32
-
33
- ctx , cancel := context .WithCancel (context .Background ())
34
-
35
- c := make (chan os.Signal , 2 )
36
- signal .Notify (c , shutdownSignals ... )
37
- go func () {
38
- <- c
39
- cancel ()
40
- <- c
41
- os .Exit (1 ) // second signal. Exit directly.
42
- }()
43
-
44
- return ctx
45
- }
23
+ var SetupSignalHandler = apiserver .SetupSignalContext
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments