mirror of
https://github.com/safing/portbase
synced 2025-09-01 18:19:57 +00:00
Expose config change event name
This commit is contained in:
parent
48711570af
commit
055c220a58
3 changed files with 5 additions and 6 deletions
|
@ -80,7 +80,7 @@ func registerBasicOptions() error {
|
||||||
// Register to hook to update the log level.
|
// Register to hook to update the log level.
|
||||||
if err := module.RegisterEventHook(
|
if err := module.RegisterEventHook(
|
||||||
"config",
|
"config",
|
||||||
configChangeEvent,
|
ChangeEvent,
|
||||||
"update log level",
|
"update log level",
|
||||||
setLogLevel,
|
setLogLevel,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
|
|
|
@ -16,9 +16,8 @@ import (
|
||||||
"github.com/safing/portbase/utils/debug"
|
"github.com/safing/portbase/utils/debug"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
// ChangeEvent is the name of the config change event.
|
||||||
configChangeEvent = "config change"
|
const ChangeEvent = "config change"
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
module *modules.Module
|
module *modules.Module
|
||||||
|
@ -36,7 +35,7 @@ func SetDataRoot(root *utils.DirStructure) {
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
module = modules.Register("config", prep, start, nil, "database")
|
module = modules.Register("config", prep, start, nil, "database")
|
||||||
module.RegisterEvent(configChangeEvent, true)
|
module.RegisterEvent(ChangeEvent, true)
|
||||||
|
|
||||||
flag.BoolVar(&exportConfig, "export-config-options", false, "export configuration registry and exit")
|
flag.BoolVar(&exportConfig, "export-config-options", false, "export configuration registry and exit")
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ func signalChanges() {
|
||||||
validityFlag = abool.NewBool(true)
|
validityFlag = abool.NewBool(true)
|
||||||
validityFlagLock.Unlock()
|
validityFlagLock.Unlock()
|
||||||
|
|
||||||
module.TriggerEvent(configChangeEvent, nil)
|
module.TriggerEvent(ChangeEvent, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// replaceConfig sets the (prioritized) user defined config.
|
// replaceConfig sets the (prioritized) user defined config.
|
||||||
|
|
Loading…
Add table
Reference in a new issue