Created
July 13, 2018 07:09
-
-
Save amitsaha/67082d0ae9f8a78dcb80ebeaaef86a5f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"os" | |
"os/signal" | |
"syscall" | |
"time" | |
) | |
func main1() { | |
signalChannel := make(chan os.Signal, 2) | |
signal.Notify(signalChannel, os.Interrupt, syscall.SIGTERM) | |
go func() { | |
// Continuously monitor for signals | |
for { | |
log.Printf("Waiting for signal") | |
sig := <-signalChannel | |
switch sig { | |
case os.Interrupt: | |
log.Printf("Got Interrupt\n") | |
case syscall.SIGTERM: | |
log.Printf("Got SIGTERM\n") | |
default: | |
log.Printf("Got %v", sig) | |
} | |
} | |
}() | |
for { | |
log.Printf("Running with PID: %d\n", os.Getpid()) | |
time.Sleep(36000 * time.Second) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment