2017-12-04 11:59:11 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
"os/signal"
|
|
|
|
"syscall"
|
|
|
|
|
|
|
|
"git.loafle.net/commons_go/logging"
|
|
|
|
"git.loafle.net/overflow/overflow_probe_container_network/server"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2017-12-14 08:51:08 +00:00
|
|
|
pidPath *string
|
2017-12-04 11:59:11 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2017-12-14 08:51:08 +00:00
|
|
|
pidPath = flag.String("pid-path", "/tmp/network-container.pid", "The path of pid file")
|
2017-12-04 11:59:11 +00:00
|
|
|
flag.Parse()
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
defer logging.Logger().Sync()
|
|
|
|
|
2017-12-14 08:51:08 +00:00
|
|
|
s := server.New(*pidPath)
|
2017-12-04 11:59:11 +00:00
|
|
|
|
|
|
|
go func() {
|
|
|
|
if err := s.Start(); nil != err {
|
|
|
|
log.Printf("Server: Start error %v", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
2017-12-18 08:55:05 +00:00
|
|
|
// // Set up channel on which to send signal notifications.
|
|
|
|
// // We must use a buffered channel or risk missing the signal
|
|
|
|
// // if we're not ready to receive when the signal is sent.
|
|
|
|
interrupt := make(chan os.Signal, 1)
|
|
|
|
signal.Notify(interrupt,
|
|
|
|
syscall.SIGKILL,
|
|
|
|
syscall.SIGSTOP,
|
|
|
|
syscall.SIGHUP,
|
|
|
|
syscall.SIGINT,
|
|
|
|
syscall.SIGTERM,
|
|
|
|
syscall.SIGQUIT)
|
|
|
|
|
|
|
|
<-interrupt
|
2017-12-04 11:59:11 +00:00
|
|
|
|
|
|
|
s.Stop()
|
|
|
|
|
|
|
|
}
|