Installation of scheduler service added into enterprise server installer
This commit is contained in:
parent
02a2fa50b9
commit
efa7af35a1
6 changed files with 112 additions and 25 deletions
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Include>
|
||||
<?define PROJECTPATH = "..\..\..\WebsitePanel"?>
|
||||
<?define BUILDPATH = "$(var.PROJECTPATH)\Build\$(var.BUILD)\SchedulerService\bin"?>
|
||||
<?define BUILDPATH = "$(var.PROJECTPATH)\Build\$(var.BUILD)\EnterpriseServer\bin"?>
|
||||
<?define SERVERBUILDPATH = "$(var.PROJECTPATH)\Build\$(var.BUILD)\Server\bin"?>
|
||||
</Include>
|
||||
|
|
|
@ -102,6 +102,74 @@ namespace WebsitePanel.Setup.Actions
|
|||
}
|
||||
}
|
||||
|
||||
public class InstallSchedulerServiceAction : Action, IInstallAction, IUninstallAction
|
||||
{
|
||||
public const string LogStartInstallMessage = "Installing Scheduler Windows Service...";
|
||||
public const string LogStartUninstallMessage = "Uninstalling Scheduler Windows Service...";
|
||||
|
||||
void IInstallAction.Run(SetupVariables vars)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
Begin(LogStartInstallMessage);
|
||||
|
||||
Log.WriteStart(LogStartInstallMessage);
|
||||
Log.WriteInfo(String.Format("Scheduler Service Name: \"{0}\"", Global.Parameters.SchedulerServiceName));
|
||||
|
||||
if (ServiceController.GetServices().Any(s => s.DisplayName.Equals(Global.Parameters.SchedulerServiceName, StringComparison.CurrentCultureIgnoreCase)))
|
||||
{
|
||||
Log.WriteEnd("Scheduler Service Already Installed.");
|
||||
InstallLog.AppendLine(String.Format("- Scheduler Service \"{0}\" Already Installed.", Global.Parameters.SchedulerServiceName));
|
||||
return;
|
||||
}
|
||||
|
||||
ManagedInstallerClass.InstallHelper(new[] { "/i", Path.Combine(vars.InstallationFolder, "bin", Global.Parameters.SchedulerServiceFileName) });
|
||||
Utils.StartService(Global.Parameters.SchedulerServiceName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
UninstallService(vars);
|
||||
|
||||
if (Utils.IsThreadAbortException(ex))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Log.WriteError("Installing scheduler service error.", ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void IUninstallAction.Run(SetupVariables vars)
|
||||
{
|
||||
try
|
||||
{
|
||||
Log.WriteStart(LogStartUninstallMessage);
|
||||
UninstallService(vars);
|
||||
Log.WriteEnd("Scheduler Service Uninstalled.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (Utils.IsThreadAbortException(ex))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Log.WriteError("Uninstalling scheduler service error.", ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private void UninstallService(SetupVariables vars)
|
||||
{
|
||||
if (ServiceController.GetServices().Any(s => s.ServiceName.Equals(Global.Parameters.SchedulerServiceName, StringComparison.CurrentCultureIgnoreCase)))
|
||||
{
|
||||
ManagedInstallerClass.InstallHelper(new[] { "/u", Path.Combine(vars.InstallationFolder, "bin", Global.Parameters.SchedulerServiceFileName) });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class CreateDatabaseAction : Action, IInstallAction, IUninstallAction
|
||||
{
|
||||
public const string LogStartInstallMessage = "Creating SQL Server database...";
|
||||
|
@ -351,6 +419,31 @@ namespace WebsitePanel.Setup.Actions
|
|||
}
|
||||
}
|
||||
|
||||
public class SaveSchedulerServiceConnectionStringAction : Action, IInstallAction
|
||||
{
|
||||
void IInstallAction.Run(SetupVariables vars)
|
||||
{
|
||||
Log.WriteStart(string.Format("Updating {0}.config file (connection string)", Global.Parameters.SchedulerServiceFileName));
|
||||
var file = Path.Combine(vars.InstallationFolder, "bin", string.Format("{0}.config", Global.Parameters.SchedulerServiceFileName));
|
||||
string content;
|
||||
|
||||
using (var reader = new StreamReader(file))
|
||||
{
|
||||
content = reader.ReadToEnd();
|
||||
}
|
||||
|
||||
vars.ConnectionString = String.Format(vars.ConnectionString, vars.DatabaseServer, vars.Database, vars.Database, vars.DatabaseUserPassword);
|
||||
content = Utils.ReplaceScriptVariable(content, "installer.connectionstring", vars.ConnectionString);
|
||||
|
||||
using (var writer = new StreamWriter(file))
|
||||
{
|
||||
writer.Write(content);
|
||||
}
|
||||
|
||||
Log.WriteEnd(string.Format("Updated {0}.config file (connection string)", Global.Parameters.SchedulerServiceFileName));
|
||||
}
|
||||
}
|
||||
|
||||
public class SaveEntServerConfigSettingsAction : Action, IInstallAction
|
||||
{
|
||||
void IInstallAction.Run(SetupVariables vars)
|
||||
|
@ -393,7 +486,9 @@ namespace WebsitePanel.Setup.Actions
|
|||
new UpdateServeradminPasswAction(),
|
||||
new SaveAspNetDbConnectionStringAction(),
|
||||
new SaveComponentConfigSettingsAction(),
|
||||
new SaveEntServerConfigSettingsAction()
|
||||
new SaveEntServerConfigSettingsAction(),
|
||||
new SaveSchedulerServiceConnectionStringAction(),
|
||||
new InstallSchedulerServiceAction()
|
||||
};
|
||||
|
||||
public EntServerActionManager(SetupVariables sessionVars) : base(sessionVars)
|
||||
|
|
|
@ -76,7 +76,9 @@ namespace WebsitePanel.Setup
|
|||
public const string DatabaseName = "DatabaseName";
|
||||
public const string ConnectionString = "ConnectionString";
|
||||
public const string InstallConnectionString = "InstallConnectionString";
|
||||
public const string Release = "Release";
|
||||
public const string Release = "Release";
|
||||
public const string SchedulerServiceFileName = "WebsitePanel.SchedulerService.exe";
|
||||
public const string SchedulerServiceName = "WebsitePanel Scheduler";
|
||||
}
|
||||
|
||||
public abstract class Messages
|
||||
|
|
|
@ -290,6 +290,13 @@ namespace WebsitePanel.Setup
|
|||
list.Add(action);
|
||||
}
|
||||
|
||||
if (ServiceController.GetServices().Any(s => s.DisplayName.Equals(Global.Parameters.SchedulerServiceName, StringComparison.CurrentCultureIgnoreCase)))
|
||||
{
|
||||
action = new InstallAction(ActionTypes.UnregisterWindowsService) { Path = Path.Combine(installFolder, "bin", Global.Parameters.SchedulerServiceFileName), Name = Global.Parameters.SchedulerServiceName, Description = "Removing Windows service..." };
|
||||
action.Log = string.Format("- Remove {0} Windows service", action.Name);
|
||||
list.Add(action);
|
||||
}
|
||||
|
||||
//database
|
||||
bool deleteDatabase = AppConfig.GetComponentSettingBooleanValue(componentId, "NewDatabase");
|
||||
if (deleteDatabase)
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<OutputPath>..\WebsitePanel.EnterpriseServer\bin\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
|
|
|
@ -164,25 +164,7 @@
|
|||
<Copy SourceFiles="@(EnterpriseServerBuildFiles)" DestinationFolder="$(EnterpriseServerBuild)\%(RecursiveDir)" />
|
||||
</Target>
|
||||
|
||||
<Target Name="CreateSchedulerServiceBuild" DependsOnTargets="CreateEnterpriseServerBuild">
|
||||
<ItemGroup>
|
||||
<SchedulerServiceBuildExclude Include="$(SchedulerServiceSrc)\**\.svn\**" />
|
||||
<SchedulerServiceBuildExclude Include="$(SchedulerServiceSrc)\**\obj\**" />
|
||||
<SchedulerServiceBuildExclude Include="$(SchedulerServiceSrc)\bin\*.xml" />
|
||||
<SchedulerServiceBuildExclude Include="$(SchedulerServiceSrc)\**\Release\**" />
|
||||
<SchedulerServiceBuildExclude Include="$(SchedulerServiceSrc)\**\Debug\**" />
|
||||
<SchedulerServiceBuildExclude Include="$(SchedulerServiceSrc)\**\Images\**" />
|
||||
<SchedulerServiceBuildExclude Include="$(SchedulerServiceSrc)\**\*.pdb" Condition="'$(BuildConfiguration)' == 'Release'" />
|
||||
<SchedulerServiceBuildExclude Include="$(SchedulerServiceSrc)\**\*.user" />
|
||||
<SchedulerServiceBuildExclude Include="$(SchedulerServiceSrc)\**\*.suo" />
|
||||
<SchedulerServiceBuildExclude Include="$(SchedulerServiceSrc)\**\*.cs" />
|
||||
<SchedulerServiceBuildExclude Include="$(SchedulerServiceSrc)\**\*.csproj" />
|
||||
<SchedulerServiceBuildFiles Include="$(SchedulerServiceSrc)\**\*.*" Exclude="@(SchedulerServiceBuildExclude)"/>
|
||||
</ItemGroup>
|
||||
<Copy SourceFiles="@(SchedulerServiceBuildFiles)" DestinationFolder="$(SchedulerServiceBuild)\%(RecursiveDir)" />
|
||||
</Target>
|
||||
|
||||
<Target Name="CreatePortalBuild" DependsOnTargets="CreateSchedulerServiceBuild">
|
||||
<Target Name="CreatePortalBuild" DependsOnTargets="CreateEnterpriseServerBuild">
|
||||
<ItemGroup>
|
||||
<PortalBuildExclude Include="$(PortalSrc)\**\.svn\**" />
|
||||
<PortalBuildExclude Include="$(PortalSrc)\**\obj\**" />
|
||||
|
@ -395,6 +377,7 @@
|
|||
<MakeDir Directories="$(EnterpriseServerInstall)"/>
|
||||
<Copy SourceFiles="@(EnterpriseServerDeployFiles)" DestinationFolder="$(EnterpriseServerInstall)\%(RecursiveDir)" />
|
||||
<XmlUpdate XmlFileName="$(EnterpriseServerInstall)\web.config" Xpath="//configuration/connectionStrings/add/@connectionString" Value="${installer.connectionstring}" />
|
||||
<XmlUpdate XmlFileName="$(EnterpriseServerInstall)\bin\WebsitePanel.SchedulerService.exe.config" Xpath="//configuration/connectionStrings/add/@connectionString" Value="${installer.connectionstring}" />
|
||||
<XmlUpdate XmlFileName="$(EnterpriseServerInstall)\web.config" Xpath="//configuration/appSettings/add[@key=%22WebsitePanel.CryptoKey%22]/@value" Value="${installer.cryptokey}" />
|
||||
</Target>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue