New: Hand-off update logic to handle upstart/systemd and other auto-restart mechanisms.

pull/3113/head
Taloth Saldono 10 years ago
parent e5278a0243
commit 7d23f24854

@ -78,8 +78,11 @@ namespace NzbDrone.Update.UpdateEngine
var appType = _detectApplicationType.GetAppType();
try
{
if (OsInfo.IsWindows)
{
_terminateNzbDrone.Terminate(processId);
}
_backupAndRestore.Backup(installationFolder);
_backupAppData.Backup();
@ -92,7 +95,7 @@ namespace NzbDrone.Update.UpdateEngine
_logger.Info("Copying new files to target folder");
_diskProvider.CopyFolder(_appFolderInfo.GetUpdatePackageFolder(), installationFolder);
// Set executable flag on SOnarr app
// Set executable flag on Sonarr app
if (OsInfo.IsOsx)
{
_diskProvider.SetPermissions(Path.Combine(installationFolder, "Sonarr"), "0755", null, null);
@ -105,9 +108,33 @@ namespace NzbDrone.Update.UpdateEngine
}
}
finally
{
if (OsInfo.IsWindows)
{
_startNzbDrone.Start(appType, installationFolder);
}
else
{
_terminateNzbDrone.Terminate(processId);
_logger.Info("Waiting for external auto-restart.");
for (int i = 0; i < 5; i++)
{
System.Threading.Thread.Sleep(1000);
if (_processProvider.Exists(ProcessProvider.NZB_DRONE_PROCESS_NAME))
{
_logger.Info("Sonarr was restarted by external process.");
break;
}
}
if (!_processProvider.Exists(ProcessProvider.NZB_DRONE_PROCESS_NAME))
{
_startNzbDrone.Start(appType, installationFolder);
}
}
}
}
}

Loading…
Cancel
Save