From cc2c4e7d27653f1970a1de2db78168eecb3306a1 Mon Sep 17 00:00:00 2001 From: crusader Date: Wed, 21 Mar 2018 20:05:04 +0900 Subject: [PATCH] ing --- build.sh | 2 +- crawler/impl/ssh/client/client.go | 4 ++-- main.go | 30 ++++++++++++++---------------- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/build.sh b/build.sh index a554c85..67167d7 100755 --- a/build.sh +++ b/build.sh @@ -1,4 +1,4 @@ rm ./dist/* CGO_ENABLED=0 go build -a --installsuffix cgo --ldflags="-s" -o ./dist/overflow_probe_container_network -cp ./dist/overflow_probe_container_network /project/overFlow/ +cp ./dist/overflow_probe_container_network /project/overFlow/probe/bin/ diff --git a/crawler/impl/ssh/client/client.go b/crawler/impl/ssh/client/client.go index 88417bc..bf82e95 100644 --- a/crawler/impl/ssh/client/client.go +++ b/crawler/impl/ssh/client/client.go @@ -4,9 +4,9 @@ import ( "bytes" "fmt" "io/ioutil" - "log" "time" + "git.loafle.net/commons_go/logging" cuej "git.loafle.net/commons_go/util/encoding/json" configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" "golang.org/x/crypto/ssh" @@ -69,7 +69,7 @@ func (cli *SSHClient) RunCommand(command string) ([]byte, error) { var b bytes.Buffer session.Stdout = &b - log.Printf("%s \n", command) + logging.Logger().Debugf("%s \n", command) if err := session.Run(command); nil != err { return nil, err } diff --git a/main.go b/main.go index 61164d2..c0d7195 100644 --- a/main.go +++ b/main.go @@ -2,22 +2,26 @@ package main import ( "flag" - "log" "os" "os/signal" "syscall" "git.loafle.net/commons_go/logging" + oocc "git.loafle.net/overflow/overflow_commons_go/config" "git.loafle.net/overflow/overflow_probe_container_network/server" ) var ( - pidPath *string + pidPath *string + logConfigPath *string ) func init() { - pidPath = flag.String("pid-path", "/tmp/network-container.pid", "The path of pid file") + pidPath = oocc.FlagPidFilePath("./dist/network.pid") + logConfigPath = oocc.FlagLogConfigFilePath("") flag.Parse() + + logging.InitializeLogger(*logConfigPath) } func main() { @@ -27,24 +31,18 @@ func main() { go func() { if err := s.Start(); nil != err { - log.Printf("Server: Start error %v", err) + logging.Logger().Infof("Server: Start error %v", err) return } }() - // // 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) + stop := make(chan os.Signal) + signal.Notify(stop, syscall.SIGINT) - <-interrupt + select { + case signal := <-stop: + logging.Logger().Infof("Got signal: %v\n", signal) + } s.Stop()