This commit is contained in:
crusader 2018-03-21 20:05:04 +09:00
parent 514a2b348c
commit cc2c4e7d27
3 changed files with 17 additions and 19 deletions

View File

@ -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/

View File

@ -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
}

30
main.go
View File

@ -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()