Gets public IP every hour
This commit is contained in:
@@ -223,6 +223,7 @@ func _main(background context.Context, args []string) int {
|
|||||||
|
|
||||||
publicIPLooper := publicip.NewLooper(client, logger, fileManager, allSettings.System.IPStatusFilepath, uid, gid)
|
publicIPLooper := publicip.NewLooper(client, logger, fileManager, allSettings.System.IPStatusFilepath, uid, gid)
|
||||||
go publicIPLooper.Run(ctx, restartPublicIP)
|
go publicIPLooper.Run(ctx, restartPublicIP)
|
||||||
|
go publicIPLooper.RunRestartTicker(ctx, restartPublicIP)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
first := true
|
first := true
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import (
|
|||||||
|
|
||||||
type Looper interface {
|
type Looper interface {
|
||||||
Run(ctx context.Context, restart <-chan struct{})
|
Run(ctx context.Context, restart <-chan struct{})
|
||||||
|
RunRestartTicker(ctx context.Context, restart chan<- struct{})
|
||||||
}
|
}
|
||||||
|
|
||||||
type looper struct {
|
type looper struct {
|
||||||
@@ -71,3 +72,16 @@ func (l *looper) Run(ctx context.Context, restart <-chan struct{}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (l *looper) RunRestartTicker(ctx context.Context, restart chan<- struct{}) {
|
||||||
|
ticker := time.NewTicker(time.Hour)
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
ticker.Stop()
|
||||||
|
return
|
||||||
|
case <-ticker.C:
|
||||||
|
restart <- struct{}{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user