From 8f4a52d7396c0dc20270e7644eebe5d9fc49eed9 Mon Sep 17 00:00:00 2001 From: cyoung Date: Fri, 1 Feb 2019 16:06:22 -0500 Subject: [PATCH] Call `gracefulShutdown()` before reboot. Fixes #717. --- main/gen_gdl90.go | 4 ++-- main/managementinterface.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/main/gen_gdl90.go b/main/gen_gdl90.go index 1ff0b0bb..912b04bc 100644 --- a/main/gen_gdl90.go +++ b/main/gen_gdl90.go @@ -1446,7 +1446,7 @@ func openReplayFile(fn string) ReadCloser { var stratuxClock *monotonic var sigs = make(chan os.Signal, 1) // Signal catch channel (shutdown). -// Graceful shutdown. +// Graceful shutdown. Do everything except for kill the process. func gracefulShutdown() { // Shut down SDRs. sdrKill() @@ -1463,7 +1463,6 @@ func gracefulShutdown() { // Turn off green ACT LED on the Pi. ioutil.WriteFile("/sys/class/leds/led0/brightness", []byte("0\n"), 0644) - os.Exit(1) } // Close log file handle, open new one. @@ -1489,6 +1488,7 @@ func signalWatcher() { } else { log.Printf("signal caught: %s - shutting down.\n", sig.String()) gracefulShutdown() + os.Exit(1) } } } diff --git a/main/managementinterface.go b/main/managementinterface.go index a0328d44..cc74fd2e 100644 --- a/main/managementinterface.go +++ b/main/managementinterface.go @@ -414,14 +414,14 @@ func handleSettingsSetRequest(w http.ResponseWriter, r *http.Request) { func handleShutdownRequest(w http.ResponseWriter, r *http.Request) { syscall.Sync() - syscall.Reboot(syscall.LINUX_REBOOT_CMD_POWER_OFF) gracefulShutdown() + syscall.Reboot(syscall.LINUX_REBOOT_CMD_POWER_OFF) } func doReboot() { syscall.Sync() - syscall.Reboot(syscall.LINUX_REBOOT_CMD_RESTART) gracefulShutdown() + syscall.Reboot(syscall.LINUX_REBOOT_CMD_RESTART) } func handleDeleteLogFile(w http.ResponseWriter, r *http.Request) {