12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- package main
- import (
- "Wx_MP/Nats"
- "Wx_MP/Server"
- "Wx_MP/conf"
- "Wx_MP/logs"
- _ "Wx_MP/routers"
- beego "github.com/beego/beego/v2/server/web"
- "github.com/beego/beego/v2/server/web/filter/cors"
- "strconv"
- "time"
- )
- func init() {
- // 定时 更新 微信AccessToke
- go func() {
- for true {
- logs.Println("================ 定时更新 GetAccessToken =================")
- Server.GetAccessToken(true)
- time.Sleep(10 * time.Minute)
- }
- }()
- Nats.NatsInit()
- }
- func main() {
- HTTPPort_int, _ := strconv.Atoi(conf.HTTPPort)
- beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
- AllowAllOrigins: true,
- AllowMethods: []string{"*"},
- AllowHeaders: []string{"Origin", "Authorization", "Access-Control-Allow-Origin"},
- ExposeHeaders: []string{"Content-Length", "Access-Control-Allow-Origin"},
- AllowCredentials: true,
- }))
- beego.BConfig.AppName = conf.AppName // 项目名
- beego.BConfig.ServerName = conf.AppName + conf.HTTPPort //server 名称
- beego.BConfig.RunMode = "dev" // 应用的运行模式
- beego.BConfig.Listen.HTTPPort = HTTPPort_int //监听端口 本地:8518 线上:8528
- logs.Println("======= beego.Run ======")
- beego.Run()
- }
|