Hidden startup, shutodwn and restart
New: Run without console window by default New: Added NzbDrone.Console to run with console window New: Shutdown from UI New: Restart from UI
This commit is contained in:
@@ -45,7 +45,5 @@ namespace NzbDrone
|
||||
MonitoringProvider.AppDomainException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
Console,
|
||||
Help,
|
||||
InstallService,
|
||||
UninstallService
|
||||
UninstallService,
|
||||
Service
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>NzbDrone</RootNamespace>
|
||||
<AssemblyName>NzbDrone.Console</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
|
||||
<RestorePackages>true</RestorePackages>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<UseVSHostingProcess>true</UseVSHostingProcess>
|
||||
<CodeAnalysisRuleSet>BasicCorrectnessRules.ruleset</CodeAnalysisRuleSet>
|
||||
<IntermediateOutputPath>C:\Users\Mark\AppData\Local\Temp\vs32F1.tmp\x86\Debug\</IntermediateOutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<IntermediateOutputPath>C:\Users\Mark\AppData\Local\Temp\vs32F1.tmp\x86\Release\</IntermediateOutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>NzbDrone.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject>NzbDrone.AppMain</StartupObject>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
</Reference>
|
||||
<Reference Include="EnvDTE80, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
</Reference>
|
||||
<Reference Include="Ninject, Version=3.0.0.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Ninject.3.0.1.10\lib\net40\Ninject.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NLog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.ServiceProcess" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\NzbDrone.Common\Properties\SharedAssemblyInfo.cs">
|
||||
<Link>Properties\SharedAssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="ApplicationServer.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="CentralDispatch.cs" />
|
||||
<Compile Include="Model\ApplicationMode.cs" />
|
||||
<Compile Include="Providers\DebuggerProvider.cs" />
|
||||
<Compile Include="ProcessAttacher.cs" />
|
||||
<Compile Include="AppMain.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Providers\MonitoringProvider.cs" />
|
||||
<Compile Include="Router.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="NzbDrone.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include=".NETFramework,Version=v4.0">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Microsoft .NET Framework 4 %28x86 and x64%29</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Windows Installer 3.1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\NzbDrone.Common\NzbDrone.Common.csproj">
|
||||
<Project>{F2BE0FDF-6E47-4827-A420-DD4EF82407F8}</Project>
|
||||
<Name>NzbDrone.Common</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>
|
||||
</PreBuildEvent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -6,7 +6,7 @@
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{D12F7F2F-8A3C-415F-88FA-6DD061A84869}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>NzbDrone</RootNamespace>
|
||||
<AssemblyName>NzbDrone</AssemblyName>
|
||||
|
||||
+64
-41
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
@@ -15,73 +16,94 @@ namespace NzbDrone
|
||||
private readonly ServiceProvider _serviceProvider;
|
||||
private readonly ConsoleProvider _consoleProvider;
|
||||
private readonly EnvironmentProvider _environmentProvider;
|
||||
private readonly ProcessProvider _processProvider;
|
||||
|
||||
public Router(ApplicationServer applicationServer, ServiceProvider serviceProvider, ConsoleProvider consoleProvider, EnvironmentProvider environmentProvider)
|
||||
public Router(ApplicationServer applicationServer, ServiceProvider serviceProvider,
|
||||
ConsoleProvider consoleProvider, EnvironmentProvider environmentProvider,
|
||||
ProcessProvider processProvider)
|
||||
{
|
||||
_applicationServer = applicationServer;
|
||||
_serviceProvider = serviceProvider;
|
||||
_consoleProvider = consoleProvider;
|
||||
_environmentProvider = environmentProvider;
|
||||
_processProvider = processProvider;
|
||||
}
|
||||
|
||||
public void Route(IEnumerable<string> args)
|
||||
{
|
||||
|
||||
Route(GetApplicationMode(args));
|
||||
}
|
||||
|
||||
public void Route(ApplicationMode applicationMode)
|
||||
{
|
||||
logger.Info("Application mode: {0}", applicationMode);
|
||||
logger.Info("Application mode: {0}", applicationMode);
|
||||
|
||||
//TODO:move this outside, it should be one of application modes (ApplicationMode.Service?)
|
||||
if (!_environmentProvider.IsUserInteractive)
|
||||
if(!_environmentProvider.IsUserInteractive)
|
||||
{
|
||||
_serviceProvider.Run(_applicationServer);
|
||||
applicationMode = ApplicationMode.Service;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
switch (applicationMode)
|
||||
{
|
||||
{
|
||||
case ApplicationMode.Service:
|
||||
{
|
||||
_serviceProvider.Run(_applicationServer);
|
||||
break;
|
||||
}
|
||||
|
||||
case ApplicationMode.Console:
|
||||
case ApplicationMode.Console:
|
||||
{
|
||||
_applicationServer.Start();
|
||||
_consoleProvider.WaitForClose();
|
||||
break;
|
||||
}
|
||||
case ApplicationMode.InstallService:
|
||||
{
|
||||
if (_serviceProvider.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME))
|
||||
{
|
||||
_applicationServer.Start();
|
||||
_consoleProvider.WaitForClose();
|
||||
break;
|
||||
_consoleProvider.PrintServiceAlreadyExist();
|
||||
}
|
||||
case ApplicationMode.InstallService:
|
||||
else
|
||||
{
|
||||
if (_serviceProvider.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME))
|
||||
{
|
||||
_consoleProvider.PrintServiceAlreadyExist();
|
||||
}
|
||||
else
|
||||
{
|
||||
_serviceProvider.Install(ServiceProvider.NZBDRONE_SERVICE_NAME);
|
||||
_serviceProvider.Start(ServiceProvider.NZBDRONE_SERVICE_NAME);
|
||||
}
|
||||
break;
|
||||
_serviceProvider.Install(ServiceProvider.NZBDRONE_SERVICE_NAME);
|
||||
_serviceProvider.Start(ServiceProvider.NZBDRONE_SERVICE_NAME);
|
||||
}
|
||||
case ApplicationMode.UninstallService:
|
||||
break;
|
||||
}
|
||||
case ApplicationMode.UninstallService:
|
||||
{
|
||||
if (!_serviceProvider.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME))
|
||||
{
|
||||
if (!_serviceProvider.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME))
|
||||
{
|
||||
_consoleProvider.PrintServiceDoestExist();
|
||||
}
|
||||
else
|
||||
{
|
||||
_serviceProvider.UnInstall(ServiceProvider.NZBDRONE_SERVICE_NAME);
|
||||
}
|
||||
_consoleProvider.PrintServiceDoestExist();
|
||||
}
|
||||
else
|
||||
{
|
||||
_serviceProvider.UnInstall(ServiceProvider.NZBDRONE_SERVICE_NAME);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
_consoleProvider.PrintHelp();
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ApplicationMode.Silent:
|
||||
{
|
||||
var startInfo = new ProcessStartInfo();
|
||||
startInfo.FileName = _environmentProvider.GetNzbDroneExe();
|
||||
startInfo.WorkingDirectory = _environmentProvider.ApplicationPath;
|
||||
|
||||
startInfo.UseShellExecute = false;
|
||||
startInfo.RedirectStandardOutput = true;
|
||||
startInfo.RedirectStandardError = true;
|
||||
startInfo.CreateNoWindow = true;
|
||||
|
||||
_processProvider.Start(startInfo);
|
||||
|
||||
Environment.Exit(0);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
_consoleProvider.PrintHelp();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,6 +119,7 @@ namespace NzbDrone
|
||||
|
||||
if (arg == "i") return ApplicationMode.InstallService;
|
||||
if (arg == "u") return ApplicationMode.UninstallService;
|
||||
if (arg == "s") return ApplicationMode.Silent;
|
||||
|
||||
return ApplicationMode.Help;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user