agent
This commit is contained in:
parent
8a41b8a835
commit
603f8656e2
20
agent.go
20
agent.go
|
@ -1,6 +1,8 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
log "github.com/cihub/seelog"
|
||||||
|
"loafle.com/overflow/agent/bootstrap"
|
||||||
"loafle.com/overflow/agent_api/config_manager"
|
"loafle.com/overflow/agent_api/config_manager"
|
||||||
msg "loafle.com/overflow/agent_api/messages"
|
msg "loafle.com/overflow/agent_api/messages"
|
||||||
col "loafle.com/overflow/collector_go"
|
col "loafle.com/overflow/collector_go"
|
||||||
|
@ -8,10 +10,9 @@ import (
|
||||||
crm "loafle.com/overflow/crawler_manager_go"
|
crm "loafle.com/overflow/crawler_manager_go"
|
||||||
dat "loafle.com/overflow/data_sender_go"
|
dat "loafle.com/overflow/data_sender_go"
|
||||||
evt "loafle.com/overflow/event_sender_go"
|
evt "loafle.com/overflow/event_sender_go"
|
||||||
|
ini "loafle.com/overflow/initializer_go"
|
||||||
pol "loafle.com/overflow/long_poller_go"
|
pol "loafle.com/overflow/long_poller_go"
|
||||||
log "github.com/cihub/seelog"
|
|
||||||
"sync"
|
"sync"
|
||||||
"loafle.com/overflow/agent/bootstrap"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -30,6 +31,7 @@ func main() {
|
||||||
type Agent struct {
|
type Agent struct {
|
||||||
cm config_manager.ConfigManager
|
cm config_manager.ConfigManager
|
||||||
taskCh chan interface{}
|
taskCh chan interface{}
|
||||||
|
secKey string
|
||||||
}
|
}
|
||||||
|
|
||||||
func StartAgent() {
|
func StartAgent() {
|
||||||
|
@ -52,6 +54,14 @@ func (agt *Agent) startAgent() {
|
||||||
}
|
}
|
||||||
globalConf := <-cfgStarted
|
globalConf := <-cfgStarted
|
||||||
|
|
||||||
|
// ini start()
|
||||||
|
iniStarted := make(chan string, 1)
|
||||||
|
if err := ini.Start(iniStarted, globalConf); err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
agt.secKey = <-iniStarted
|
||||||
|
|
||||||
//2. evt start()
|
//2. evt start()
|
||||||
evtStarted := make(chan bool, 1)
|
evtStarted := make(chan bool, 1)
|
||||||
if err := evt.Start(evtStarted); err != nil {
|
if err := evt.Start(evtStarted); err != nil {
|
||||||
|
@ -75,12 +85,12 @@ func (agt *Agent) startAgent() {
|
||||||
agt.taskCh = pol.GetTaskCh()
|
agt.taskCh = pol.GetTaskCh()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Todo : Getting an auth key from API server.
|
Todo : Getting an auth key from API server.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//5. scm start()
|
//5. scm start()
|
||||||
scmStarted := make(chan config_manager.ConfigManager, 1)
|
scmStarted := make(chan config_manager.ConfigManager, 1)
|
||||||
if err := cfg.StartSensorConfig(scmStarted, "temp"); err != nil {
|
if err := cfg.StartSensorConfig(scmStarted, agt.secKey); err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user