kopia lustrzana https://github.com/cyoung/stratux
rodzic
df6f844738
commit
033c3ca1e4
|
@ -1190,9 +1190,7 @@ func addSingleSystemErrorf(ident string, format string, a ...interface{}) {
|
|||
func saveSettings() {
|
||||
fd, err := os.OpenFile(configLocation, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, os.FileMode(0644))
|
||||
if err != nil {
|
||||
err_ret := fmt.Errorf("can't save settings %s: %s", configLocation, err.Error())
|
||||
addSystemError(err_ret)
|
||||
log.Printf("%s\n", err_ret.Error())
|
||||
addSingleSystemErrorf("save-settings", "can't save settings %s: %s", configLocation, err.Error())
|
||||
return
|
||||
}
|
||||
defer fd.Close()
|
||||
|
@ -1240,7 +1238,6 @@ func fsWriteTest(dir string) error {
|
|||
|
||||
func printStats() {
|
||||
statTimer := time.NewTicker(30 * time.Second)
|
||||
diskUsageWarning := false
|
||||
for {
|
||||
<-statTimer.C
|
||||
var memstats runtime.MemStats
|
||||
|
@ -1265,10 +1262,8 @@ func printStats() {
|
|||
log.Printf("- " + strings.Join(sensorsOutput, ", ") + "\n")
|
||||
}
|
||||
// Check if we're using more than 95% of the free space. If so, throw a warning (only once).
|
||||
if !diskUsageWarning && usage.Usage() > 0.95 {
|
||||
err_p := fmt.Errorf("Disk bytes used = %s (%.1f %%), Disk bytes free = %s (%.1f %%)", humanize.Bytes(usage.Used()), 100*usage.Usage(), humanize.Bytes(usage.Free()), 100*(1-usage.Usage()))
|
||||
addSystemError(err_p)
|
||||
diskUsageWarning = true
|
||||
if usage.Usage() > 0.95 {
|
||||
addSingleSystemErrorf("disk-space", "Disk bytes used = %s (%.1f %%), Disk bytes free = %s (%.1f %%)", humanize.Bytes(usage.Used()), 100*usage.Usage(), humanize.Bytes(usage.Free()), 100*(1-usage.Usage()))
|
||||
}
|
||||
logStatus()
|
||||
}
|
||||
|
@ -1432,11 +1427,10 @@ func main() {
|
|||
if vtF < 8.0 {
|
||||
var err_os error
|
||||
if globalStatus.HardwareBuild == "FlightBox" {
|
||||
err_os = fmt.Errorf("You are running an old Stratux image that can't be updated fully and is now deprecated. Visit https://www.openflightsolutions.com/flightbox/image-update-required for further information.")
|
||||
addSingleSystemErrorf("deprecated-image", "You are running an old Stratux image that can't be updated fully and is now deprecated. Visit https://www.openflightsolutions.com/flightbox/image-update-required for further information.")
|
||||
} else {
|
||||
err_os = fmt.Errorf("You are running an old Stratux image that can't be updated fully and is now deprecated. Visit http://stratux.me/ to update using the latest release image.")
|
||||
addSingleSystemErrorf("deprecated-image", "You are running an old Stratux image that can't be updated fully and is now deprecated. Visit http://stratux.me/ to update using the latest release image.")
|
||||
}
|
||||
addSystemError(err_os)
|
||||
} else {
|
||||
// Running Jessie or better. Remove some old init.d files.
|
||||
// This made its way in here because /etc/init.d/stratux invokes the update script, which can't delete the init.d file.
|
||||
|
@ -1473,9 +1467,7 @@ func main() {
|
|||
// Duplicate log.* output to debugLog.
|
||||
fp, err := os.OpenFile(debugLogf, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
|
||||
if err != nil {
|
||||
err_log := fmt.Errorf("Failed to open '%s': %s", debugLogf, err.Error())
|
||||
addSystemError(err_log)
|
||||
log.Printf("%s\n", err_log.Error())
|
||||
addSingleSystemErrorf(debugLogf, "Failed to open '%s': %s", debugLogf, err.Error())
|
||||
} else {
|
||||
defer fp.Close()
|
||||
// Keep the logfile handle for later use
|
||||
|
|
|
@ -654,14 +654,12 @@ func defaultServer(w http.ResponseWriter, r *http.Request) {
|
|||
func handleroPartitionRebuild(w http.ResponseWriter, r *http.Request) {
|
||||
out, err := exec.Command("/usr/sbin/rebuild_ro_part.sh").Output()
|
||||
|
||||
var ret_err error
|
||||
if err != nil {
|
||||
ret_err = fmt.Errorf("Rebuild RO Partition error: %s", err.Error())
|
||||
addSingleSystemErrorf("partition-rebuild", "Rebuild RO Partition error: %s", err.Error())
|
||||
} else {
|
||||
ret_err = fmt.Errorf("Rebuild RO Partition success: %s", out)
|
||||
addSingleSystemErrorf("partition-rebuild", "Rebuild RO Partition success: %s", out)
|
||||
}
|
||||
|
||||
addSystemError(ret_err)
|
||||
}
|
||||
|
||||
// https://gist.github.com/alexisrobert/982674.
|
||||
|
|
|
@ -76,19 +76,16 @@ const (
|
|||
extra_hosts_file = "/etc/stratux-static-hosts.conf"
|
||||
)
|
||||
|
||||
var dhcpLeaseFileWarning bool
|
||||
var dhcpLeaseDirectoryLastTest time.Time // Last time fsWriteTest() was run on the DHCP lease directory.
|
||||
|
||||
// Read the "dhcpd.leases" file and parse out IP/hostname.
|
||||
func getDHCPLeases() (map[string]string, error) {
|
||||
// Do a write test. Even if we are able to read the file, it may be out of date because there's a fs write issue.
|
||||
// Only perform the test once every 5 minutes to minimize writes.
|
||||
if !dhcpLeaseFileWarning && (stratuxClock.Since(dhcpLeaseDirectoryLastTest) >= 5*time.Minute) {
|
||||
if stratuxClock.Since(dhcpLeaseDirectoryLastTest) >= 5*time.Minute {
|
||||
err := fsWriteTest(dhcp_lease_dir)
|
||||
if err != nil {
|
||||
err_p := fmt.Errorf("Write error on '%s', your EFB may have issues receiving weather and traffic.", dhcp_lease_dir)
|
||||
addSystemError(err_p)
|
||||
dhcpLeaseFileWarning = true
|
||||
addSingleSystemErrorf("fs-write", "Write error on '%s', your EFB may have issues receiving weather and traffic.", dhcp_lease_dir)
|
||||
}
|
||||
dhcpLeaseDirectoryLastTest = stratuxClock.Time
|
||||
}
|
||||
|
@ -602,8 +599,6 @@ func networkStatsCounter() {
|
|||
*/
|
||||
|
||||
func ffMonitor() {
|
||||
ff_warned := false // Has a warning been issued via globalStatus.Errors?
|
||||
|
||||
addr := net.UDPAddr{Port: 50113, IP: net.ParseIP("0.0.0.0")}
|
||||
conn, err := net.ListenUDP("udp", &addr)
|
||||
if err != nil {
|
||||
|
@ -637,11 +632,7 @@ func ffMonitor() {
|
|||
if strings.HasPrefix(s, "i-want-to-play-ffm-udp") || strings.HasPrefix(s, "i-can-play-ffm-udp") || strings.HasPrefix(s, "i-cannot-play-ffm-udp") {
|
||||
p.FFCrippled = true
|
||||
//FIXME: AHRS output doesn't need to be disabled globally, just on the ForeFlight client IPs.
|
||||
if !ff_warned {
|
||||
e := errors.New("Stratux is not supported by your EFB app. Your EFB app is known to regularly make changes that cause compatibility issues with Stratux. See the README for a list of apps that officially support Stratux.")
|
||||
addSystemError(e)
|
||||
ff_warned = true
|
||||
}
|
||||
addSingleSystemErrorf("ff-warn", "Stratux is not supported by your EFB app. Your EFB app is known to regularly make changes that cause compatibility issues with Stratux. See the README for a list of apps that officially support Stratux.")
|
||||
}
|
||||
outSockets[ffIpAndPort] = p
|
||||
netMutex.Unlock()
|
||||
|
|
|
@ -484,8 +484,7 @@ func sdrWatcher() {
|
|||
} 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 was restarted.\n", info.Uptime)
|
||||
addSystemError(daemonRestartedErr)
|
||||
addSingleSystemErrorf("restart-warn", "System uptime %d seconds. Daemon was restarted.\n", info.Uptime)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue