1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2024-12-27 10:07:10 +00:00

Merge branch 'upstart-update' into develop

This commit is contained in:
Taloth Saldono 2015-05-21 21:57:30 +02:00
commit 527663e27e

View file

@ -78,8 +78,11 @@ public void Start(string installationFolder, int processId)
var appType = _detectApplicationType.GetAppType(); var appType = _detectApplicationType.GetAppType();
try try
{
if (OsInfo.IsWindows)
{ {
_terminateNzbDrone.Terminate(processId); _terminateNzbDrone.Terminate(processId);
}
_backupAndRestore.Backup(installationFolder); _backupAndRestore.Backup(installationFolder);
_backupAppData.Backup(); _backupAppData.Backup();
@ -92,7 +95,7 @@ public void Start(string installationFolder, int processId)
_logger.Info("Copying new files to target folder"); _logger.Info("Copying new files to target folder");
_diskProvider.CopyFolder(_appFolderInfo.GetUpdatePackageFolder(), installationFolder); _diskProvider.CopyFolder(_appFolderInfo.GetUpdatePackageFolder(), installationFolder);
// Set executable flag on SOnarr app // Set executable flag on Sonarr app
if (OsInfo.IsOsx) if (OsInfo.IsOsx)
{ {
_diskProvider.SetPermissions(Path.Combine(installationFolder, "Sonarr"), "0755", null, null); _diskProvider.SetPermissions(Path.Combine(installationFolder, "Sonarr"), "0755", null, null);
@ -105,9 +108,33 @@ public void Start(string installationFolder, int processId)
} }
} }
finally finally
{
if (OsInfo.IsWindows)
{ {
_startNzbDrone.Start(appType, installationFolder); _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);
}
}
}
} }
} }