2019-10-05 21:53:22 +05:00
|
|
|
package configuration
|
|
|
|
|
|
|
|
import (
|
|
|
|
// local
|
|
|
|
"sources.dev.pztrn.name/pztrn/giredore/internal/logger"
|
|
|
|
|
|
|
|
// other
|
|
|
|
"github.com/rs/zerolog"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
log zerolog.Logger
|
|
|
|
loggerInitialized bool
|
|
|
|
|
2019-10-07 18:21:26 +05:00
|
|
|
envCfg *envConfig
|
|
|
|
Cfg *fileConfig
|
2019-10-05 21:53:22 +05:00
|
|
|
)
|
|
|
|
|
|
|
|
func Initialize() {
|
|
|
|
log = logger.Logger.With().Str("type", "internal").Str("package", "configuration").Logger()
|
|
|
|
loggerInitialized = true
|
|
|
|
log.Info().Msg("Initializing...")
|
|
|
|
|
2019-10-07 18:21:26 +05:00
|
|
|
envCfg = &envConfig{}
|
|
|
|
envCfg.Initialize()
|
|
|
|
|
|
|
|
Cfg = &fileConfig{}
|
2019-10-05 21:53:22 +05:00
|
|
|
Cfg.Initialize()
|
2019-10-07 18:21:26 +05:00
|
|
|
|
|
|
|
Cfg.HTTP.Listen = envCfg.HTTP.Listen
|
|
|
|
Cfg.HTTP.WaitForSeconds = envCfg.HTTP.WaitForSeconds
|
|
|
|
}
|
|
|
|
|
|
|
|
func Shutdown() {
|
|
|
|
Cfg.Save()
|
2019-10-05 21:53:22 +05:00
|
|
|
}
|