1 Star 0 Fork 0

yeeeeeeeeee/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)
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yejinlei/confd.git
git@gitee.com:yejinlei/confd.git
yejinlei
confd
confd
master

搜索帮助