Merge remote-tracking branch 'origin/master'

This commit is contained in:
snoop 2017-08-08 18:26:43 +09:00
commit 1dab32e5c3
6 changed files with 43 additions and 11 deletions

View File

@ -18,6 +18,7 @@ const (
TASK_POL_INTERVAL_UPDATE = "TASK_POLLER_INTERVAL_UPDATE" TASK_POL_INTERVAL_UPDATE = "TASK_POLLER_INTERVAL_UPDATE"
DISCOVERY_START = "DISCOVERY_START" DISCOVERY_START = "DISCOVERY_START"
DISCOVERY_STOP = "DISCOVERY_STOP"
DISCOVERY_HOST_START = "DISCOVERY_HOST_START" DISCOVERY_HOST_START = "DISCOVERY_HOST_START"
DISCOVERY_HOST_FOUND = "DISCOVERY_HOST_FOUND" DISCOVERY_HOST_FOUND = "DISCOVERY_HOST_FOUND"
DISCOVERY_HOST_DONE = "DISCOVERY_HOST_DONE" DISCOVERY_HOST_DONE = "DISCOVERY_HOST_DONE"

View File

@ -1,4 +1,4 @@
central: central:
address: "http://localhost:9090" address: "http://localhost:9090"
port: 443 port: 443
log_path: "./bin/log.xml" log_path: "./discovery/bin/log.xml"

View File

@ -1,13 +1,13 @@
package main package bootstrap
import ( import (
"flag" "flag"
"fmt" "fmt"
"git.loafle.net/overflow/overflow_probe/discovery"
"git.loafle.net/overflow/overflow_probe/discovery/conf" "git.loafle.net/overflow/overflow_probe/discovery/conf"
log "github.com/cihub/seelog" log "github.com/cihub/seelog"
"os" "os"
"runtime" "runtime"
"git.loafle.net/overflow/overflow_probe/discovery"
) )
func init() { func init() {
@ -28,16 +28,12 @@ func init() {
} }
} }
func main() { func Start() {
runtime.GOMAXPROCS(runtime.NumCPU()) runtime.GOMAXPROCS(runtime.NumCPU())
defer log.Flush() defer log.Flush()
stop := make(chan bool, 1) stop := make(chan bool, 1)
go handleShell(stop) go handleShell(stop)
handleSignal(stop) handleSignal(stop)
collector.Start() collector.Start()
if <-stop { if <-stop {
@ -49,3 +45,25 @@ func main() {
os.Exit(0) os.Exit(0)
} }
} }
//func main() {
//
// runtime.GOMAXPROCS(runtime.NumCPU())
//
// defer log.Flush()
//
// stop := make(chan bool, 1)
// go handleShell(stop)
// handleSignal(stop)
//
// collector.Start()
//
// if <-stop {
// // Comes from shell cmd 'stop' or quit signals
// stopHandleShell()
// collector.Stop()
// close(stop)
// log.Flush()
// os.Exit(0)
// }
//}

View File

@ -1,4 +1,4 @@
package main package bootstrap
import ( import (
log "github.com/cihub/seelog" log "github.com/cihub/seelog"

View File

@ -1,4 +1,4 @@
package main package bootstrap
import ( import (
log "github.com/cihub/seelog" log "github.com/cihub/seelog"

View File

@ -4,6 +4,7 @@ import (
"git.loafle.net/overflow/overflow_probe/agent_api/config_manager" "git.loafle.net/overflow/overflow_probe/agent_api/config_manager"
msg "git.loafle.net/overflow/overflow_probe/agent_api/messages" msg "git.loafle.net/overflow/overflow_probe/agent_api/messages"
"git.loafle.net/overflow/overflow_probe/bootstrap" "git.loafle.net/overflow/overflow_probe/bootstrap"
discovery "git.loafle.net/overflow/overflow_probe/discovery/bootstrap"
col "git.loafle.net/overflow/overflow_probe/collector" col "git.loafle.net/overflow/overflow_probe/collector"
cfg "git.loafle.net/overflow/overflow_probe/config_manager" cfg "git.loafle.net/overflow/overflow_probe/config_manager"
crm "git.loafle.net/overflow/overflow_probe/crawler_manager" crm "git.loafle.net/overflow/overflow_probe/crawler_manager"
@ -17,7 +18,7 @@ import (
const ( const (
// /home/geek/develop/gopath/src/git.loafle.net/overflow/overflow_probe/config_manager/test_agent // /home/geek/develop/gopath/src/git.loafle.net/overflow/overflow_probe/config_manager/test_agent
PATH = "/home/insanity/Develop/gopath/src/git.loafle.net/overflow/overflow_probe/config_manager/test_agent" PATH = "/home/geek/Develop/gopath/src/git.loafle.net/overflow/overflow_probe/config_manager/test_agent"
) )
var wg sync.WaitGroup var wg sync.WaitGroup
@ -35,6 +36,7 @@ type Probe struct {
} }
func StartAgent() { func StartAgent() {
stopch := make(chan bool, 1) stopch := make(chan bool, 1)
bootstrap.HandleShell(stopch) bootstrap.HandleShell(stopch)
bootstrap.HandleSignal(stopch) bootstrap.HandleSignal(stopch)
@ -42,10 +44,14 @@ func StartAgent() {
prb := Probe{} prb := Probe{}
prb.startProbe() prb.startProbe()
// Todo discovery start delete
discovery.Start()
prb.handleProbeStop(stopch) prb.handleProbeStop(stopch)
} }
func (prb *Probe) startProbe() { func (prb *Probe) startProbe() {
//1. cfg start() //1. cfg start()
cfgStarted := make(chan *config_manager.GlobalConfig, 1) cfgStarted := make(chan *config_manager.GlobalConfig, 1)
if err := cfg.Start(cfgStarted, PATH); err != nil { if err := cfg.Start(cfgStarted, PATH); err != nil {
@ -104,6 +110,7 @@ func (prb *Probe) startProbe() {
//7. col start() //7. col start()
dataCh := make(chan interface{}) dataCh := make(chan interface{})
colStarted := make(chan bool, 1) colStarted := make(chan bool, 1)
col.Start(colStarted, dataCh, prb.cm) col.Start(colStarted, dataCh, prb.cm)
<-colStarted <-colStarted
@ -159,6 +166,12 @@ func (prb *Probe) waitAgentTask() {
case msg.TASK_LOG_SEND: case msg.TASK_LOG_SEND:
prb.processSendLog(task) prb.processSendLog(task)
break break
case msg.DISCOVERY_START:
discovery.Start()
break
case msg.DISCOVERY_STOP:
break
default: default:
} }