代码拉取完成,页面将自动刷新
同步操作将从 Ulric Qin/Nightingale 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
package main
import (
"context"
"flag"
"fmt"
"os"
"os/signal"
"syscall"
_ "github.com/go-sql-driver/mysql"
prom_runtime "github.com/prometheus/prometheus/pkg/runtime"
"github.com/toolkits/pkg/logger"
"github.com/toolkits/pkg/runner"
"github.com/didi/nightingale/v5/alert"
"github.com/didi/nightingale/v5/backend"
"github.com/didi/nightingale/v5/config"
"github.com/didi/nightingale/v5/http"
"github.com/didi/nightingale/v5/judge"
"github.com/didi/nightingale/v5/models"
"github.com/didi/nightingale/v5/pkg/i18n"
"github.com/didi/nightingale/v5/pkg/ilog"
"github.com/didi/nightingale/v5/rpc"
"github.com/didi/nightingale/v5/timer"
"github.com/didi/nightingale/v5/trans"
)
var version = "not specified"
var (
vers *bool
help *bool
)
func init() {
vers = flag.Bool("v", false, "display the version.")
help = flag.Bool("h", false, "print this help.")
flag.Parse()
if *vers {
fmt.Println("version:", version)
os.Exit(0)
}
if *help {
flag.Usage()
os.Exit(0)
}
runner.Init()
fmt.Println("runner.cwd:", runner.Cwd)
fmt.Println("runner.hostname:", runner.Hostname)
fmt.Println("fd_limits", prom_runtime.FdLimits())
fmt.Println("vm_limits", prom_runtime.VMLimits())
}
func main() {
parseConf()
ilog.Init(config.Config.Logger)
i18n.Init(config.Config.I18N)
models.InitMySQL(config.Config.MySQL)
models.InitLdap(config.Config.LDAP)
models.InitSalt()
models.InitRoot()
models.InitError()
ctx, cancelFunc := context.WithCancel(context.Background())
timer.SyncResourceTags()
timer.SyncUsers()
timer.SyncUserGroups()
timer.SyncUserGroupMember()
timer.SyncClasspathReses()
timer.SyncCollectRules()
timer.SyncAlertMutes()
timer.SyncAlertRules()
timer.SyncMetricDesc()
timer.CleanExpireMute()
timer.CleanExpireResource()
timer.BindOrphanRes()
timer.UpdateAlias()
judge.Start(ctx)
alert.Start(ctx)
trans.Start(ctx)
backend.Init(config.Config.Trans.Backend)
http.Start()
rpc.Start()
endingProc(cancelFunc)
}
func parseConf() {
if err := config.Parse(); err != nil {
fmt.Println("cannot parse configuration file:", err)
os.Exit(1)
}
}
func endingProc(cancelFunc context.CancelFunc) {
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
<-c
fmt.Printf("stop signal caught, stopping... pid=%d\n", os.Getpid())
// 执行清理工作
backend.DatasourceCleanUp()
cancelFunc()
logger.Close()
http.Shutdown()
fmt.Println("process stopped successfully")
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。