| | |
| | | import ( |
| | | "data_msg_push_server/config" |
| | | "data_msg_push_server/service" |
| | | "flag" |
| | | |
| | | "fmt" |
| | | "time" |
| | | ) |
| | | |
| | | var env = flag.String("config", "config", "read storage info") |
| | | |
| | | func init() { |
| | | config.Init(*env) |
| | | config.Init() |
| | | } |
| | | |
| | | func main() { |
| | | fmt.Println("hello!!!") |
| | | done := make(chan bool) |
| | | |
| | | go runEvery(done) |
| | | //result,err := service.GetData() |
| | | //if err != nil { |
| | | // fmt.Println(err) |
| | | //} |
| | | //if result != nil{ |
| | | // |
| | | //} |
| | | <-done |
| | | fmt.Println("程序已退出") |
| | | //fmt.Println(res) |
| | | //fmt.Println(err) |
| | | |
| | | } |
| | | |
| | | func runEvery(done chan<- bool){ |
| | | func runEvery(done chan<- bool) { |
| | | ticker := time.NewTicker(10 * time.Second) |
| | | defer ticker.Stop() |
| | | |
| | | for{ |
| | | for { |
| | | select { |
| | | case <-ticker.C: |
| | | fmt.Println("开始执行函数。。。") |
| | |
| | | } |
| | | } |
| | | |
| | | func doServer() { |
| | | func doServer() { |
| | | total := 0 |
| | | for { |
| | | t,err := service.GetTotal() |
| | | t, err := service.GetTotal() |
| | | if err != nil { |
| | | fmt.Println(err) |
| | | } |
| | |
| | | } else { |
| | | for { |
| | | connectStatus := service.ConnectControl() |
| | | fmt.Println("connectStatus: ",connectStatus) |
| | | fmt.Println("connectStatus: ", connectStatus) |
| | | if connectStatus == true { |
| | | url := config.ServUrls.ServerUrl |
| | | url := config.Options.ServerUrl |
| | | result, err1 := service.GetData() |
| | | if err1 != nil { |
| | | fmt.Println(err1) |
| | | } |
| | | id, errs2 := service.SendData(result, url) |
| | | fmt.Println("data id is: ",id) |
| | | if errs2 == nil{ |
| | | fmt.Println("data id is: ", id) |
| | | if errs2 == nil { |
| | | //delStatus := service.DeleteData(id) |
| | | markStatus := service.MarkData(id) |
| | | fmt.Println(markStatus) |