package main

import (
	"flag"
	"log"
	"net/http"
	"task"
	"time"
	"tools"
	"udptask"
	"web"

	"github.com/donnie4w/go-logger/logger"
)

var port string

func main() {
	udptask.LastNodeResponse = time.Now().Unix()
	flag.StringVar(&port, "p", "8003", "端口") //87测试分类用8004;8005projectinfo定时任务
	flag.Parse()
	logger.SetRollingDaily("./logs", "updatetime.log") //日志记录
	task.LoadLua()                                     //初始化脚本
	go Server()
	log.Println("start web at ", port)
	udptask.InitUdp()
	//UDP 监听程序
	go udptask.LastUdpJob()
	//go task.RunTask() //定时任务o_projectinfo分类
	go udptask.RunningHangyeClass() //根据内存中的行业分类udps执行分类任务
	log.Println("aiurl", tools.Config["aiurl"])
	b := make(chan bool)
	<-b
}

func Server() {
	http.ListenAndServe(":"+port, web.Route)
}
