kopia lustrzana https://github.com/cyoung/stratux
Check system uptime before SDR startup delay.
Throw a system error in developer mode if the uptime is greater than 120s and `sdrWatcher()` is restarted (usually a systemd restart).pull/660/head
rodzic
032849fab0
commit
f8646d9ebe
18
main/sdr.go
18
main/sdr.go
|
@ -10,6 +10,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
|
@ -17,6 +18,7 @@ import (
|
|||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"../godump978"
|
||||
|
@ -471,7 +473,21 @@ func sdrWatcher() {
|
|||
prevUATEnabled := false
|
||||
prevESEnabled := false
|
||||
|
||||
time.Sleep(90 * time.Second)
|
||||
// Get the system (RPi) uptime.
|
||||
info := syscall.Sysinfo_t{}
|
||||
err := syscall.Sysinfo(&info)
|
||||
if err == nil {
|
||||
// Got system uptime. Delay if and only if the system uptime is less than 120 seconds. This should be plenty of time
|
||||
// for the RPi to come up and start Stratux. Keeps the delay from happening if the daemon is auto-restarted from systemd.
|
||||
if info.Uptime < 120 {
|
||||
time.Sleep(90 * time.Second)
|
||||
} else if globalSettings.DeveloperMode {
|
||||
// Throw a "critical error" if developer mode is enabled. Alerts the developer that the daemon was restarted (possibly)
|
||||
// unexpectedly.
|
||||
daemonRestartedErr := fmt.Errorf("System uptime %d seconds. Daemon restarted.\n")
|
||||
addSystemError(daemonRestartedErr)
|
||||
}
|
||||
}
|
||||
|
||||
for {
|
||||
time.Sleep(1 * time.Second)
|
||||
|
|
Ładowanie…
Reference in New Issue