1 Star 0 Fork 0

iTransit/nacos-confd

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
confd.go 1.44 KB
一键复制 编辑 原始数据 按行查看 历史
package main
import (
"flag"
"fmt"
"os"
"os/signal"
"runtime"
"syscall"
"github.com/kelseyhightower/confd/backends"
"github.com/kelseyhightower/confd/log"
"github.com/kelseyhightower/confd/resource/template"
)
func main() {
flag.Parse()
if config.PrintVersion {
fmt.Printf("confd %s (Git SHA: %s, Go Version: %s)\n", Version, GitSHA, runtime.Version())
os.Exit(0)
}
if err := initConfig(); err != nil {
log.Fatal(err.Error())
}
log.Info("Starting confd")
storeClient, err := backends.New(config.BackendsConfig)
if err != nil {
log.Fatal(err.Error())
}
config.TemplateConfig.StoreClient = storeClient
if config.OneTime {
if err := template.Process(config.TemplateConfig); err != nil {
log.Fatal(err.Error())
}
os.Exit(0)
}
stopChan := make(chan bool)
doneChan := make(chan bool)
errChan := make(chan error, 10)
var processor template.Processor
switch {
case config.Watch:
processor = template.WatchProcessor(config.TemplateConfig, stopChan, doneChan, errChan)
default:
processor = template.IntervalProcessor(config.TemplateConfig, stopChan, doneChan, errChan, config.Interval)
}
go processor.Process()
signalChan := make(chan os.Signal, 1)
signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM)
for {
select {
case err := <-errChan:
log.Error(err.Error())
case s := <-signalChan:
log.Info(fmt.Sprintf("Captured %v. Exiting...", s))
close(doneChan)
case <-doneChan:
os.Exit(0)
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/iTransit/nacos-confd.git
git@gitee.com:iTransit/nacos-confd.git
iTransit
nacos-confd
nacos-confd
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385