discovery main change func

This commit is contained in:
geek 2017-08-08 11:48:54 +09:00
parent 464eeb2094
commit e73f03792c
5 changed files with 40 additions and 10 deletions

View File

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

View File

@ -1,13 +1,13 @@
package main
package bootstrap
import (
"flag"
"fmt"
"git.loafle.net/overflow/overflow_probe/discovery"
"git.loafle.net/overflow/overflow_probe/discovery/conf"
log "github.com/cihub/seelog"
"os"
"runtime"
"git.loafle.net/overflow/overflow_probe/discovery"
)
func init() {
@ -28,16 +28,12 @@ func init() {
}
}
func main() {
func Start() {
runtime.GOMAXPROCS(runtime.NumCPU())
defer log.Flush()
stop := make(chan bool, 1)
go handleShell(stop)
handleSignal(stop)
collector.Start()
if <-stop {
@ -49,3 +45,25 @@ func main() {
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 (
log "github.com/cihub/seelog"

View File

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

View File

@ -4,6 +4,7 @@ import (
"git.loafle.net/overflow/overflow_probe/agent_api/config_manager"
msg "git.loafle.net/overflow/overflow_probe/agent_api/messages"
"git.loafle.net/overflow/overflow_probe/bootstrap"
discovery "git.loafle.net/overflow/overflow_probe/discovery/bootstrap"
col "git.loafle.net/overflow/overflow_probe/collector"
cfg "git.loafle.net/overflow/overflow_probe/config_manager"
crm "git.loafle.net/overflow/overflow_probe/crawler_manager"
@ -24,6 +25,7 @@ var wg sync.WaitGroup
func main() {
wg.Add(1)
log.Debug("ddddddddddddddddd")
go StartAgent()
wg.Wait()
}
@ -35,17 +37,19 @@ type Probe struct {
}
func StartAgent() {
stopch := make(chan bool, 1)
bootstrap.HandleShell(stopch)
bootstrap.HandleSignal(stopch)
prb := Probe{}
prb.startProbe()
discovery.Start()
prb.handleProbeStop(stopch)
}
func (prb *Probe) startProbe() {
//1. cfg start()
cfgStarted := make(chan *config_manager.GlobalConfig, 1)
if err := cfg.Start(cfgStarted, PATH); err != nil {
@ -104,6 +108,7 @@ func (prb *Probe) startProbe() {
//7. col start()
dataCh := make(chan interface{})
colStarted := make(chan bool, 1)
col.Start(colStarted, dataCh, prb.cm)
<-colStarted
@ -159,6 +164,12 @@ func (prb *Probe) waitAgentTask() {
case msg.TASK_LOG_SEND:
prb.processSendLog(task)
break
case msg.DISCOVERY_START:
discovery.Start()
break
case msg.DISCOVERY_STOP:
break
default:
}