You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
866 B
Go

package main
import (
"autogo/crontask"
"autogo/dbsql"
"autogo/router"
"flag"
"fmt"
"os"
_ "autogo/docs"
log "github.com/sirupsen/logrus"
)
var (
ENV string
)
func init() {
// 从环境变量读取mysql密码
pwd := os.Getenv("MYSQL_PASSWD")
pwd = "Flatincbr.com"
if pwd == "" {
fmt.Println("环境变量 MYSQL_PASSWD 不存在")
os.Exit(1)
}
// 设置mysql密码
dbsql.SetDSN(pwd)
flag.StringVar(&ENV, "env", "dev", "测试环境")
}
func main() {
flag.Parse()
if ENV == "dev" {
fmt.Println("dev开发模式")
} else if ENV == "prod" {
fmt.Println("prod生产模式")
go crontask.Run()
}
dbsql.DSN = dbsql.DSN_local
// env.InitDB()
log.SetLevel(log.DebugLevel)
log.SetReportCaller(true)
port := ":6364"
// 创建路由
r := router.InitRoute()
r.Run(port)
}