discovery main change func
This commit is contained in:
parent
464eeb2094
commit
e73f03792c
@ -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"
|
||||||
|
@ -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)
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package main
|
package bootstrap
|
||||||
|
|
||||||
import (
|
import (
|
||||||
log "github.com/cihub/seelog"
|
log "github.com/cihub/seelog"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package main
|
package bootstrap
|
||||||
|
|
||||||
import (
|
import (
|
||||||
log "github.com/cihub/seelog"
|
log "github.com/cihub/seelog"
|
||||||
|
13
probe.go
13
probe.go
@ -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"
|
||||||
@ -24,6 +25,7 @@ var wg sync.WaitGroup
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
|
log.Debug("ddddddddddddddddd")
|
||||||
go StartAgent()
|
go StartAgent()
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
}
|
}
|
||||||
@ -35,17 +37,19 @@ 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)
|
||||||
|
|
||||||
prb := Probe{}
|
prb := Probe{}
|
||||||
prb.startProbe()
|
prb.startProbe()
|
||||||
|
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 +108,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 +164,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:
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user