1 Star 0 Fork 210

Shiro/next-terminal

forked from dushixiang/next-terminal
暂停
 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
main.go 1.50 KB
一键复制 编辑 原始数据 按行查看 历史
dushixiang 提交于 2021-10-31 17:15 . release v1.2.0
package main
import (
"encoding/json"
"fmt"
"next-terminal/server/api"
"next-terminal/server/config"
"next-terminal/server/constant"
"next-terminal/server/repository"
"next-terminal/server/task"
"github.com/labstack/gommon/log"
)
func main() {
err := Run()
if err != nil {
log.Fatal(err)
}
}
func Run() error {
fmt.Printf(constant.Banner, constant.Version)
if config.GlobalCfg.Debug {
jsonBytes, err := json.MarshalIndent(config.GlobalCfg, "", " ")
if err != nil {
return err
}
fmt.Printf("当前配置为: %v\n", string(jsonBytes))
}
db := api.SetupDB()
e := api.SetupRoutes(db)
if config.GlobalCfg.ResetPassword != "" {
return api.ResetPassword(config.GlobalCfg.ResetPassword)
}
if config.GlobalCfg.ResetTotp != "" {
return api.ResetTotp(config.GlobalCfg.ResetTotp)
}
if config.GlobalCfg.NewEncryptionKey != "" {
return api.ChangeEncryptionKey(config.GlobalCfg.EncryptionKey, config.GlobalCfg.NewEncryptionKey)
}
sessionRepo := repository.NewSessionRepository(db)
propertyRepo := repository.NewPropertyRepository(db)
loginLogRepo := repository.NewLoginLogRepository(db)
jobLogRepo := repository.NewJobLogRepository(db)
ticker := task.NewTicker(sessionRepo, propertyRepo, loginLogRepo, jobLogRepo)
ticker.SetupTicker()
if config.GlobalCfg.Server.Cert != "" && config.GlobalCfg.Server.Key != "" {
return e.StartTLS(config.GlobalCfg.Server.Addr, config.GlobalCfg.Server.Cert, config.GlobalCfg.Server.Key)
} else {
return e.Start(config.GlobalCfg.Server.Addr)
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/shunzi115/next-terminal.git
git@gitee.com:shunzi115/next-terminal.git
shunzi115
next-terminal
next-terminal
master

搜索帮助