app pool restart thing out of the way and force dedicated app pool thing that I approved
This commit is contained in:
parent
580a898523
commit
cfd0b39673
14 changed files with 767 additions and 396 deletions
|
@ -1422,6 +1422,27 @@ namespace WebsitePanel.EnterpriseServer {
|
|||
}
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/ChangeAppPoolState", RequestNamespace = "http://smbsaas/websitepanel/enterpriseserver", ResponseNamespace = "http://smbsaas/websitepanel/enterpriseserver", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
|
||||
public int ChangeAppPoolState(int siteItemId, AppPoolState state)
|
||||
{
|
||||
object[] results = this.Invoke("ChangeAppPoolState", new object[] {
|
||||
siteItemId,
|
||||
state});
|
||||
return ((int)(results[0]));
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/GetAppPoolState", RequestNamespace = "http://smbsaas/websitepanel/enterpriseserver", ResponseNamespace = "http://smbsaas/websitepanel/enterpriseserver", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
|
||||
public AppPoolState GetAppPoolState(int siteItemId)
|
||||
{
|
||||
object[] results = this.Invoke("GetAppPoolState", new object[] {
|
||||
siteItemId
|
||||
});
|
||||
return ((AppPoolState)(results[0]));
|
||||
}
|
||||
|
||||
|
||||
/// <remarks/>
|
||||
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/GetSharedSSLDomains", RequestNamespace="http://smbsaas/websitepanel/enterpriseserver", ResponseNamespace="http://smbsaas/websitepanel/enterpriseserver", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
|
||||
public string[] GetSharedSSLDomains(int packageId) {
|
||||
|
|
|
@ -583,6 +583,89 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
}
|
||||
|
||||
// AppPool
|
||||
public static int ChangeAppPoolState(int siteItemId, AppPoolState state)
|
||||
{
|
||||
// check account
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
|
||||
if (accountCheck < 0) return accountCheck;
|
||||
|
||||
// load site item
|
||||
WebSite siteItem = (WebSite)PackageController.GetPackageItem(siteItemId);
|
||||
if (siteItem == null)
|
||||
return BusinessErrorCodes.ERROR_WEB_SITE_PACKAGE_ITEM_NOT_FOUND;
|
||||
|
||||
// check package
|
||||
int packageCheck = SecurityContext.CheckPackage(siteItem.PackageId, DemandPackage.IsActive);
|
||||
if (packageCheck < 0) return packageCheck;
|
||||
|
||||
// place log record
|
||||
TaskManager.StartTask("WEB_SITE", "CHANGE_STATE", siteItem.Name);
|
||||
TaskManager.ItemId = siteItemId;
|
||||
TaskManager.WriteParameter("New state", state);
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
// change state
|
||||
WebServer web = new WebServer();
|
||||
ServiceProviderProxy.Init(web, siteItem.ServiceId);
|
||||
web.ChangeAppPoolState(siteItem.SiteId, state);
|
||||
|
||||
return 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw TaskManager.WriteError(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
}
|
||||
|
||||
public static AppPoolState GetAppPoolState(int siteItemId)
|
||||
{
|
||||
AppPoolState state = AppPoolState.Unknown;
|
||||
|
||||
// check account
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
|
||||
if (accountCheck < 0) return state;
|
||||
|
||||
// load site item
|
||||
WebSite siteItem = (WebSite)PackageController.GetPackageItem(siteItemId);
|
||||
if (siteItem == null)
|
||||
return state;
|
||||
|
||||
// check package
|
||||
int packageCheck = SecurityContext.CheckPackage(siteItem.PackageId, DemandPackage.IsActive);
|
||||
if (packageCheck < 0) return state;
|
||||
|
||||
// place log record
|
||||
TaskManager.StartTask("WEB_SITE", "GET_STATE", siteItem.Name);
|
||||
TaskManager.ItemId = siteItemId;
|
||||
|
||||
try
|
||||
{
|
||||
// get state
|
||||
WebServer web = new WebServer();
|
||||
ServiceProviderProxy.Init(web, siteItem.ServiceId);
|
||||
state = web.GetAppPoolState(siteItem.SiteId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw TaskManager.WriteError(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static int DeleteWebSite(int siteItemId, bool deleteWebsiteDirectory)
|
||||
{
|
||||
// check account
|
||||
|
|
|
@ -181,6 +181,20 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return WebServerController.ChangeSiteState(siteItemId, state);
|
||||
}
|
||||
|
||||
// AppPool
|
||||
[WebMethod]
|
||||
public int ChangeAppPoolState(int siteItemId, AppPoolState state)
|
||||
{
|
||||
return WebServerController.ChangeAppPoolState(siteItemId, state);
|
||||
}
|
||||
|
||||
[WebMethod]
|
||||
public AppPoolState GetAppPoolState(int siteItemId)
|
||||
{
|
||||
return WebServerController.GetAppPoolState(siteItemId);
|
||||
}
|
||||
|
||||
|
||||
#region Shared SSL Folders
|
||||
[WebMethod]
|
||||
public List<string> GetSharedSSLDomains(int packageId)
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
using System;
|
||||
|
||||
namespace WebsitePanel.Providers
|
||||
{
|
||||
[Serializable]
|
||||
public enum AppPoolState
|
||||
{
|
||||
Unknown = 0,
|
||||
Start = 1,
|
||||
Stop = 2,
|
||||
Recycle = 3
|
||||
}
|
||||
}
|
|
@ -54,6 +54,10 @@ namespace WebsitePanel.Providers.Web
|
|||
void UpdateSiteBindings(string siteId, ServerBinding[] bindings, bool emptyBindingsAllowed);
|
||||
void DeleteSite(string siteId);
|
||||
|
||||
// AppPool
|
||||
void ChangeAppPoolState(string siteId, AppPoolState state);
|
||||
AppPoolState GetAppPoolState(string siteId);
|
||||
|
||||
// virtual directories
|
||||
bool VirtualDirectoryExists(string siteId, string directoryName);
|
||||
WebVirtualDirectory[] GetVirtualDirectories(string siteId);
|
||||
|
|
|
@ -72,6 +72,7 @@
|
|||
<Compile Include="..\VersionInfo.cs">
|
||||
<Link>VersionInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="Common\AppPoolState.cs" />
|
||||
<Compile Include="Common\ByteOperations.cs" />
|
||||
<Compile Include="Common\ErrorCodes.cs" />
|
||||
<Compile Include="Common\PasswdHelper.cs" />
|
||||
|
|
|
@ -1524,6 +1524,27 @@ namespace WebsitePanel.Providers.Web
|
|||
}
|
||||
}
|
||||
|
||||
// AppPool
|
||||
public void ChangeAppPoolState(string siteId, AppPoolState state)
|
||||
{
|
||||
webObjectsSvc.ChangeAppPoolState(siteId, state);
|
||||
}
|
||||
|
||||
public AppPoolState GetAppPoolState(string siteId)
|
||||
{
|
||||
using (ServerManager srvman = webObjectsSvc.GetServerManager())
|
||||
{
|
||||
return GetAppPoolState(srvman, siteId);
|
||||
}
|
||||
}
|
||||
|
||||
public AppPoolState GetAppPoolState(ServerManager srvman, string siteId)
|
||||
{
|
||||
return webObjectsSvc.GetAppPoolState(srvman, siteId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether virtual iisDirObject with supplied name under specified site exists.
|
||||
/// </summary>
|
||||
|
|
|
@ -348,6 +348,91 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
|
|||
return siteState;
|
||||
}
|
||||
|
||||
// AppPool
|
||||
public void ChangeAppPoolState(string siteId, AppPoolState state)
|
||||
{
|
||||
// del
|
||||
File.AppendAllText(@"c:\websitepanel\test.log", "ChangeAppPoolState " + siteId + " state " + state.ToString() + "\r\n");
|
||||
|
||||
using (var srvman = GetServerManager())
|
||||
{
|
||||
var site = srvman.Sites[siteId];
|
||||
//
|
||||
if (site == null)
|
||||
return;
|
||||
|
||||
string AppPoolName = site.ApplicationDefaults.ApplicationPoolName;
|
||||
foreach (Application app in site.Applications)
|
||||
AppPoolName = app.ApplicationPoolName;
|
||||
|
||||
if (string.IsNullOrEmpty(AppPoolName))
|
||||
return;
|
||||
|
||||
ApplicationPool pool = srvman.ApplicationPools[AppPoolName];
|
||||
if (pool == null) return;
|
||||
|
||||
//
|
||||
switch (state)
|
||||
{
|
||||
case AppPoolState.Start:
|
||||
pool.Start();
|
||||
pool.AutoStart = true;
|
||||
break;
|
||||
case AppPoolState.Stop:
|
||||
pool.Stop();
|
||||
pool.AutoStart = false;
|
||||
break;
|
||||
case AppPoolState.Recycle:
|
||||
pool.Recycle();
|
||||
pool.AutoStart = true;
|
||||
break;
|
||||
}
|
||||
//
|
||||
srvman.CommitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public AppPoolState GetAppPoolState(ServerManager srvman, string siteId)
|
||||
{
|
||||
Site site = srvman.Sites[siteId];
|
||||
|
||||
// ensure website exists
|
||||
if (site == null)
|
||||
return AppPoolState.Unknown;
|
||||
|
||||
string AppPoolName = site.ApplicationDefaults.ApplicationPoolName;
|
||||
foreach (Application app in site.Applications)
|
||||
AppPoolName = app.ApplicationPoolName;
|
||||
|
||||
if (string.IsNullOrEmpty(AppPoolName))
|
||||
return AppPoolState.Unknown;
|
||||
|
||||
ApplicationPool pool = srvman.ApplicationPools[AppPoolName];
|
||||
|
||||
if (pool == null) return AppPoolState.Unknown;
|
||||
|
||||
AppPoolState state = AppPoolState.Unknown;
|
||||
|
||||
switch (pool.State)
|
||||
{
|
||||
case ObjectState.Started:
|
||||
state = AppPoolState.Start;
|
||||
break;
|
||||
case ObjectState.Starting:
|
||||
state = AppPoolState.Start;
|
||||
break;
|
||||
case ObjectState.Stopped:
|
||||
state = AppPoolState.Stop;
|
||||
break;
|
||||
case ObjectState.Stopping:
|
||||
state = AppPoolState.Stop;
|
||||
break;
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
public bool SiteExists(ServerManager srvman, string siteId)
|
||||
{
|
||||
return (srvman.Sites[siteId] != null);
|
||||
|
|
|
@ -849,6 +849,16 @@ namespace WebsitePanel.Providers.Web
|
|||
}
|
||||
}
|
||||
|
||||
// AppPool
|
||||
public void ChangeAppPoolState(string siteId, AppPoolState state)
|
||||
{
|
||||
}
|
||||
|
||||
public AppPoolState GetAppPoolState(string siteId)
|
||||
{
|
||||
return AppPoolState.Unknown;
|
||||
}
|
||||
|
||||
public virtual void UpdateSiteBindings(string siteId, ServerBinding[] bindings, bool emptyBindingsAllowed)
|
||||
{
|
||||
ManagementObject objSite = wmi.GetObject(String.Format("IIsWebServerSetting='{0}'", siteId));
|
||||
|
|
|
@ -593,6 +593,27 @@ namespace WebsitePanel.Providers.Web {
|
|||
}
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
[System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")]
|
||||
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/ChangeAppPoolState", RequestNamespace = "http://smbsaas/websitepanel/server/", ResponseNamespace = "http://smbsaas/websitepanel/server/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
|
||||
public void ChangeAppPoolState(string siteId, AppPoolState state)
|
||||
{
|
||||
this.Invoke("ChangeAppPoolState", new object[] {
|
||||
siteId,
|
||||
state});
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
[System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")]
|
||||
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/GetAppPoolState", RequestNamespace = "http://smbsaas/websitepanel/server/", ResponseNamespace = "http://smbsaas/websitepanel/server/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
|
||||
public AppPoolState GetAppPoolState(string siteId)
|
||||
{
|
||||
object[] results = this.Invoke("GetAppPoolState", new object[] {
|
||||
siteId});
|
||||
return ((AppPoolState)(results[0]));
|
||||
}
|
||||
|
||||
|
||||
/// <remarks/>
|
||||
[System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")]
|
||||
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/GetSiteId", RequestNamespace="http://smbsaas/websitepanel/server/", ResponseNamespace="http://smbsaas/websitepanel/server/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
|
||||
|
|
|
@ -259,6 +259,41 @@ namespace WebsitePanel.Server
|
|||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
// AppPool
|
||||
[WebMethod, SoapHeader("settings")]
|
||||
public void ChangeAppPoolState(string siteId, AppPoolState state)
|
||||
{
|
||||
try
|
||||
{
|
||||
Log.WriteStart("'{0}' ChangeAppPoolState", ProviderSettings.ProviderName);
|
||||
WebProvider.ChangeAppPoolState(siteId, state);
|
||||
Log.WriteEnd("'{0}' ChangeAppPoolState", ProviderSettings.ProviderName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.WriteError(String.Format("'{0}' ChangeAppPoolState", ProviderSettings.ProviderName), ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[WebMethod, SoapHeader("settings")]
|
||||
public AppPoolState GetAppPoolState(string siteId)
|
||||
{
|
||||
try
|
||||
{
|
||||
Log.WriteStart("'{0}' GetAppPoolState", ProviderSettings.ProviderName);
|
||||
AppPoolState result = WebProvider.GetAppPoolState(siteId);
|
||||
Log.WriteEnd("'{0}' GetAppPoolState", ProviderSettings.ProviderName);
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.WriteError(String.Format("'{0}' GetAppPoolState", ProviderSettings.ProviderName), ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Virtual Directories
|
||||
|
|
|
@ -169,6 +169,13 @@
|
|||
<td class="MediumBold" align="center">
|
||||
<asp:Literal ID="litStatus" runat="server"></asp:Literal>
|
||||
</td>
|
||||
|
||||
<%-- AppPool --%>
|
||||
<td class="MediumBold" align="center">
|
||||
App Pool : <asp:Literal ID="litAppPoolStatus" runat="server"></asp:Literal>
|
||||
</td>
|
||||
<%-- AppPool --%>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
|
@ -181,6 +188,15 @@
|
|||
<asp:ImageButton ID="cmdStop" runat="server" SkinID="StopMedium" meta:resourcekey="cmdStop"
|
||||
CommandName="Stopped" OnClick="cmdChangeState_Click" />
|
||||
</td>
|
||||
|
||||
<%-- AppPool --%>
|
||||
<td align="center">
|
||||
<asp:LinkButton ID="cmdAppPoolStart" runat="server" CommandName="Start" OnClick="cmdAppPoolChangeState_Click">Start</asp:LinkButton><br />
|
||||
<asp:LinkButton ID="cmdAppPoolStop" runat="server" CommandName="Stop" OnClick="cmdAppPoolChangeState_Click">Stop</asp:LinkButton><br />
|
||||
<asp:LinkButton ID="cmdAppPoolRecycle" runat="server" CommandName="Recycle" OnClick="cmdAppPoolChangeState_Click">Recycle</asp:LinkButton>
|
||||
</td>
|
||||
<%-- AppPool --%>
|
||||
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
|
|
|
@ -291,6 +291,9 @@ namespace WebsitePanel.Portal
|
|||
|
||||
// bind state
|
||||
BindSiteState(site.SiteState);
|
||||
// AppPool
|
||||
AppPoolState appPoolState = ES.Services.WebServers.GetAppPoolState(PanelRequest.ItemID);
|
||||
BindAppPoolState(appPoolState);
|
||||
|
||||
// bind pointers
|
||||
BindPointers();
|
||||
|
@ -988,6 +991,42 @@ namespace WebsitePanel.Portal
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// AppPool
|
||||
private void BindAppPoolState(AppPoolState state)
|
||||
{
|
||||
litAppPoolStatus.Text = state.ToString();
|
||||
|
||||
cmdAppPoolStart.Visible = (state == AppPoolState.Stop);
|
||||
cmdAppPoolStop.Visible = (state == AppPoolState.Start);
|
||||
cmdAppPoolRecycle.Visible = (state == AppPoolState.Start);
|
||||
}
|
||||
|
||||
|
||||
protected void cmdAppPoolChangeState_Click(object sender, EventArgs e)
|
||||
{
|
||||
string stateName = ((LinkButton)sender).CommandName;
|
||||
AppPoolState state = (AppPoolState)Enum.Parse(typeof(AppPoolState), stateName, true);
|
||||
|
||||
try
|
||||
{
|
||||
int result = ES.Services.WebServers.ChangeAppPoolState(PanelRequest.ItemID, state);
|
||||
if (result < 0)
|
||||
{
|
||||
ShowResultMessage(result);
|
||||
return;
|
||||
}
|
||||
|
||||
state = ES.Services.WebServers.GetAppPoolState(PanelRequest.ItemID);
|
||||
BindAppPoolState(state);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ShowErrorMessage("WEB_CHANGE_SITE_STATE", ex);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Pointers
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue