mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
Add a signal handler to pause.
It returns 0 when a signal is received.
This commit is contained in:
parent
f9e5477e2b
commit
9b747c3a9d
@ -18,9 +18,16 @@ limitations under the License.
|
||||
|
||||
package main
|
||||
|
||||
import "syscall"
|
||||
import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Halts execution, waiting on signal.
|
||||
syscall.Pause()
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, os.Interrupt, os.Kill, syscall.SIGTERM)
|
||||
|
||||
// Block until a signal is received.
|
||||
<-c
|
||||
}
|
||||
|
@ -3,4 +3,9 @@
|
||||
set -e
|
||||
set -x
|
||||
|
||||
# Build the binary.
|
||||
go build --ldflags '-extldflags "-static" -s' pause.go
|
||||
|
||||
# Run goupx to shrink binary size.
|
||||
go get github.com/pwaller/goupx
|
||||
goupx pause
|
||||
|
Loading…
Reference in New Issue
Block a user