Skip to content

Commit

Permalink
Adding base watchdog function
Browse files Browse the repository at this point in the history
  • Loading branch information
COMTOP1 committed Feb 18, 2024
1 parent 92732f1 commit 6aa8033
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
4 changes: 4 additions & 0 deletions server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ func main() {

r.loadRoutes()

watchdog := r.views.InitWatchdog()

watchdog.Begin()

log.Printf("streamer server version: %s\n", Version)

r.router.Logger.Error(r.router.Start(r.config.ServerAddress))
Expand Down
5 changes: 5 additions & 0 deletions server/views/views.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ type (
// TransporterUnique is the payload to send to the client
TransporterUnique transporter.TransporterUnique
}

Watchdog struct {
conf Config
store *store.Store
}
)

const (
Expand Down
24 changes: 24 additions & 0 deletions server/views/watchdog.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package views

import (
"log"
"time"
)

func (v *Views) InitWatchdog() *Watchdog {
return &Watchdog{
conf: v.conf,
store: v.store,
}
}

func (w *Watchdog) Begin() {
go func() {
for {
if w.conf.Verbose {
log.Printf("watchdog called")
}
time.Sleep(5 * time.Second)
}
}()
}

0 comments on commit 6aa8033

Please sign in to comment.