add once
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
"Interval": "1s",
|
"Interval": "1s",
|
||||||
"States": ["NC"]
|
"States": ["NC"],
|
||||||
|
"Once": true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ type Config struct {
|
|||||||
Interval Duration
|
Interval Duration
|
||||||
States []State
|
States []State
|
||||||
Storage []string
|
Storage []string
|
||||||
|
Once bool
|
||||||
|
|
||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
db storage.DB
|
db storage.DB
|
||||||
|
|||||||
4
main.go
4
main.go
@@ -22,8 +22,12 @@ func _main() error {
|
|||||||
if err := once(); err != nil {
|
if err := once(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if config.Get().Once {
|
||||||
|
break
|
||||||
|
}
|
||||||
time.Sleep(config.Get().Interval.Get())
|
time.Sleep(config.Get().Interval.Get())
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func once() error {
|
func once() error {
|
||||||
|
|||||||
Reference in New Issue
Block a user