mirror of
https://github.com/crazy-max/diun.git
synced 2025-12-21 13:23:09 +01:00
Configuration transposed into environment variables (#82)
Configuration file not required anymore DIUN_DB env var renamed DIUN_DB_PATH Only accept duration as timeout value (10 becomes 10s) Add getting started doc Enhanced documentation Add note about test notifications (#79) Improve configuration management Fix telegram init All fields in configuration now camelCased Improve configuration validation Update doc Update FAQ Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
27
cmd/main.go
27
cmd/main.go
@@ -5,6 +5,7 @@ import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"runtime"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
@@ -20,15 +21,25 @@ var (
|
||||
diun *app.Diun
|
||||
cli model.Cli
|
||||
version = "dev"
|
||||
meta = model.Meta{
|
||||
ID: "diun",
|
||||
Name: "Diun",
|
||||
Desc: "Docker image update notifier",
|
||||
URL: "https://github.com/crazy-max/diun",
|
||||
Logo: "https://raw.githubusercontent.com/crazy-max/diun/master/.res/diun.png",
|
||||
Author: "CrazyMax",
|
||||
}
|
||||
)
|
||||
|
||||
func main() {
|
||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||
meta.Version = version
|
||||
meta.UserAgent = fmt.Sprintf("%s/%s go/%s %s", meta.ID, meta.Version, runtime.Version()[2:], strings.Title(runtime.GOOS))
|
||||
|
||||
// Parse command line
|
||||
_ = kong.Parse(&cli,
|
||||
kong.Name("diun"),
|
||||
kong.Description(`Docker image update notifier. More info: https://github.com/crazy-max/diun`),
|
||||
kong.Name(meta.ID),
|
||||
kong.Description(fmt.Sprintf("%s. More info: %s", meta.Desc, meta.URL)),
|
||||
kong.UsageOnError(),
|
||||
kong.Vars{
|
||||
"version": fmt.Sprintf("%s", version),
|
||||
@@ -46,7 +57,7 @@ func main() {
|
||||
|
||||
// Init
|
||||
logging.Configure(&cli, location)
|
||||
log.Info().Msgf("Starting Diun %s", version)
|
||||
log.Info().Str("version", version).Msgf("Starting %s", meta.Name)
|
||||
|
||||
// Handle os signals
|
||||
channel := make(chan os.Signal)
|
||||
@@ -59,15 +70,15 @@ func main() {
|
||||
}()
|
||||
|
||||
// Load configuration
|
||||
cfg, err := config.Load(cli, version)
|
||||
cfg, err := config.Load(cli.Cfgfile)
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Cannot load configuration")
|
||||
}
|
||||
log.Debug().Msg(cfg.Display())
|
||||
log.Debug().Msg(cfg.String())
|
||||
|
||||
// Init
|
||||
if diun, err = app.New(cfg, location); err != nil {
|
||||
log.Fatal().Err(err).Msg("Cannot initialize Diun")
|
||||
if diun, err = app.New(meta, cfg, location); err != nil {
|
||||
log.Fatal().Err(err).Msgf("Cannot initialize %s", meta.Name)
|
||||
}
|
||||
|
||||
// Test notif
|
||||
@@ -78,6 +89,6 @@ func main() {
|
||||
|
||||
// Start
|
||||
if err = diun.Start(); err != nil {
|
||||
log.Fatal().Err(err).Msg("Cannot start Diun")
|
||||
log.Fatal().Err(err).Msgf("Cannot start %s", meta.Name)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user