Fixing Sonarr restart on *nix platforms

From my understanding when Sonarr is running on a *nix platform restarting from the UI works like so:

  1. Click restart on the UI.
  2. SpinService stops sleeping.
  3. SpinService spawns a new process with /restart flag.
  4. Spawned process kills the original instance.

This has unintended consequences when using a process manager (upstart, smf, etc).
Because the original processes is killed, the process manager assumes that the process crashed and tries to restart it. It also closes the original stderr and stdout file descriptors. So if the process manager was logging stdout and stderr it will fail to log the newly restarted process.

I’m proposing that for *nix platforms that we replace steps 3 and 4 with the execv system calls. Mono provides it as Mono.Unix.Native.Syscall.execv().

This will cause the new process to replace the current process, which will keep the same PID allowing the process manager to keep tracking the same process, and it will also keep the std* file descriptors open allowing logging to continue.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.