Skip to content

Commit

Permalink
Call gracefulShutdown() before reboot.
Browse files Browse the repository at this point in the history
Fixes #717.
  • Loading branch information
cyoung committed Feb 1, 2019
1 parent 39bb2e3 commit 8f4a52d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions main/gen_gdl90.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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.
Expand All @@ -1489,6 +1488,7 @@ func signalWatcher() {
} else {
log.Printf("signal caught: %s - shutting down.\n", sig.String())
gracefulShutdown()
os.Exit(1)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions main/managementinterface.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 8f4a52d

Please sign in to comment.