slave.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package main
  2. import (
  3. cfg2 "cicv-data-closedloop/kinglong/common/cfg"
  4. commonInit "cicv-data-closedloop/kinglong/common/init"
  5. "cicv-data-closedloop/kinglong/common/log"
  6. svc3 "cicv-data-closedloop/kinglong/common/svc"
  7. slaveConfig "cicv-data-closedloop/kinglong/slave/pkg/cfg"
  8. svc4 "cicv-data-closedloop/kinglong/slave/pkg/svc"
  9. )
  10. // init 初始化函数
  11. func init() {
  12. //runtime.GOMAXPROCS(1)
  13. log.InitLogConfig("kinglong-slave")
  14. commonInit.Init()
  15. slaveConfig.InitTcpListener()
  16. cfg2.InitKillSignalListener(cfg2.CloudConfig.Hosts[1].Ip)
  17. // 等待重启,接收到重启信号,会把信号分发给以下channel
  18. go svc3.WaitKillSelf()
  19. }
  20. // main 主函数
  21. func main() {
  22. // 1 负责打包数据到data目录
  23. go svc3.BagRecord(cfg2.CloudConfig.Hosts[1].Name)
  24. // 2 负责监控故障,并修改timeWindow
  25. go svc4.PrepareTimeWindowProducerQueue()
  26. // 3
  27. go svc4.RunTimeWindowProducerQueue()
  28. // 4 排队运行时间窗口
  29. go svc3.RunTimeWindowConsumerQueue(cfg2.CloudConfig.Hosts[1].Name)
  30. // 阻塞主线程,等待其他线程执行。
  31. select {}
  32. }