Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created app pool recycle command line tool
- Loading branch information
0 parents
commit 29c4ae1
Showing
13 changed files
with
276 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,7 @@ | |||
.svn/entries | |||
.svn | |||
AppPoolRecycle.5.1.ReSharper | |||
bin | |||
obj | |||
*Resharper | |||
__ReSharper.AppPoolRecycle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,23 @@ | |||
<Configuration> | |||
<SettingsComponent> | |||
<string /> | |||
<integer /> | |||
<boolean> | |||
<setting name="SolutionAnalysisEnabled">False</setting> | |||
</boolean> | |||
</SettingsComponent> | |||
<RecentFiles> | |||
<RecentFiles /> | |||
<RecentEdits /> | |||
</RecentFiles> | |||
<NAntValidationSettings> | |||
<NAntPath value="" /> | |||
</NAntValidationSettings> | |||
<UnitTestRunner> | |||
<Providers /> | |||
</UnitTestRunner> | |||
<UnitTestRunnerNUnit> | |||
<NUnitInstallDir>C:\Program Files (x86)\NUnit 2.5.5\bin\net-2.0\</NUnitInstallDir> | |||
<UseAddins>Never</UseAddins> | |||
</UnitTestRunnerNUnit> | |||
</Configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,20 @@ | |||
|
|||
Microsoft Visual Studio Solution File, Format Version 10.00 | |||
# Visual Studio 2008 | |||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppPoolRecycle", "AppPoolRecycle\AppPoolRecycle.csproj", "{B1963AB2-DEC7-49E0-BAD8-2956E2519B2E}" | |||
EndProject | |||
Global | |||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | |||
Debug|Any CPU = Debug|Any CPU | |||
Release|Any CPU = Release|Any CPU | |||
EndGlobalSection | |||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | |||
{B1963AB2-DEC7-49E0-BAD8-2956E2519B2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||
{B1963AB2-DEC7-49E0-BAD8-2956E2519B2E}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||
{B1963AB2-DEC7-49E0-BAD8-2956E2519B2E}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||
{B1963AB2-DEC7-49E0-BAD8-2956E2519B2E}.Release|Any CPU.Build.0 = Release|Any CPU | |||
EndGlobalSection | |||
GlobalSection(SolutionProperties) = preSolution | |||
HideSolutionNode = FALSE | |||
EndGlobalSection | |||
EndGlobal |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,65 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||
<PropertyGroup> | |||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | |||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | |||
<ProductVersion>9.0.30729</ProductVersion> | |||
<SchemaVersion>2.0</SchemaVersion> | |||
<ProjectGuid>{B1963AB2-DEC7-49E0-BAD8-2956E2519B2E}</ProjectGuid> | |||
<OutputType>Exe</OutputType> | |||
<AppDesignerFolder>Properties</AppDesignerFolder> | |||
<RootNamespace>AppPoolRecycle</RootNamespace> | |||
<AssemblyName>apr</AssemblyName> | |||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> | |||
<FileAlignment>512</FileAlignment> | |||
</PropertyGroup> | |||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | |||
<DebugSymbols>true</DebugSymbols> | |||
<DebugType>full</DebugType> | |||
<Optimize>false</Optimize> | |||
<OutputPath>bin\Debug\</OutputPath> | |||
<DefineConstants>DEBUG;TRACE</DefineConstants> | |||
<ErrorReport>prompt</ErrorReport> | |||
<WarningLevel>4</WarningLevel> | |||
</PropertyGroup> | |||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | |||
<DebugType>pdbonly</DebugType> | |||
<Optimize>true</Optimize> | |||
<OutputPath>bin\Release\</OutputPath> | |||
<DefineConstants>TRACE</DefineConstants> | |||
<ErrorReport>prompt</ErrorReport> | |||
<WarningLevel>4</WarningLevel> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<Reference Include="Microsoft.Web.Administration, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> | |||
<SpecificVersion>False</SpecificVersion> | |||
<HintPath>..\lib\Microsoft.Web.Administration.dll</HintPath> | |||
</Reference> | |||
<Reference Include="System" /> | |||
<Reference Include="System.Core"> | |||
<RequiredTargetFramework>3.5</RequiredTargetFramework> | |||
</Reference> | |||
<Reference Include="System.Xml.Linq"> | |||
<RequiredTargetFramework>3.5</RequiredTargetFramework> | |||
</Reference> | |||
<Reference Include="System.Data.DataSetExtensions"> | |||
<RequiredTargetFramework>3.5</RequiredTargetFramework> | |||
</Reference> | |||
<Reference Include="System.Data" /> | |||
<Reference Include="System.Xml" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Compile Include="AppPoolRecycleCommand.cs" /> | |||
<Compile Include="AppPoolRecycleConfig.cs" /> | |||
<Compile Include="Program.cs" /> | |||
<Compile Include="Properties\AssemblyInfo.cs" /> | |||
</ItemGroup> | |||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,5 @@ | |||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | |||
<StartArguments>local.toptable.com</StartArguments> | |||
</PropertyGroup> | |||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,28 @@ | |||
using System; | |||
|
|||
namespace AppPoolRecycle | |||
{ | |||
public class AppPoolRecycleCommand | |||
{ | |||
private readonly AppPoolRecycleConfig _config; | |||
|
|||
public AppPoolRecycleCommand(AppPoolRecycleConfig config) | |||
{ | |||
_config = config; | |||
} | |||
|
|||
public void Execute() | |||
{ | |||
var serverManager = _config.GetServerManager(); | |||
var appPool = serverManager.ApplicationPools[_config.AppPoolName]; | |||
|
|||
if(null == appPool) | |||
{ | |||
throw new NullReferenceException(string.Format("The app pool {0} does not exist", _config.AppPoolName)); | |||
} | |||
|
|||
appPool.Recycle(); | |||
Console.WriteLine("Recycled {0}", _config.AppPoolName); | |||
} | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,46 @@ | |||
using System; | |||
using Microsoft.Web.Administration; | |||
|
|||
namespace AppPoolRecycle | |||
{ | |||
public class AppPoolRecycleConfig | |||
{ | |||
public string AppPoolName { get; set; } | |||
public string RemoteServerName { get; set; } | |||
|
|||
public AppPoolRecycleConfig(string[] args) | |||
{ | |||
Parse(args); | |||
} | |||
|
|||
private void Parse(string[] args) | |||
{ | |||
if(args.Length == 0 || args.Length > 2) | |||
{ | |||
throw new ArgumentException("Incorrect arguments\n" + Example); | |||
} | |||
|
|||
AppPoolName = args[0]; | |||
|
|||
if(args.Length == 2) | |||
{ | |||
RemoteServerName = args[1]; | |||
} | |||
} | |||
|
|||
public ServerManager GetServerManager() | |||
{ | |||
if(string.IsNullOrEmpty(RemoteServerName)) | |||
{ | |||
return new ServerManager(); | |||
} | |||
|
|||
return ServerManager.OpenRemote(RemoteServerName); | |||
} | |||
|
|||
private string Example | |||
{ | |||
get { return "apr [app pool name] [remote server name (optional)]"; } | |||
} | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,23 @@ | |||
using System; | |||
|
|||
namespace AppPoolRecycle | |||
{ | |||
class Program | |||
{ | |||
static void Main(string[] args) | |||
{ | |||
try | |||
{ | |||
new AppPoolRecycleCommand(new AppPoolRecycleConfig(args)) | |||
.Execute(); | |||
|
|||
Environment.ExitCode = 0; | |||
} | |||
catch (Exception ex) | |||
{ | |||
Console.WriteLine(ex.Message); | |||
Environment.ExitCode = 1; | |||
} | |||
} | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,36 @@ | |||
using System.Reflection; | |||
using System.Runtime.CompilerServices; | |||
using System.Runtime.InteropServices; | |||
|
|||
// General Information about an assembly is controlled through the following | |||
// set of attributes. Change these attribute values to modify the information | |||
// associated with an assembly. | |||
[assembly: AssemblyTitle("AppPoolRecycle")] | |||
[assembly: AssemblyDescription("")] | |||
[assembly: AssemblyConfiguration("")] | |||
[assembly: AssemblyCompany("Microsoft")] | |||
[assembly: AssemblyProduct("AppPoolRecycle")] | |||
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")] | |||
[assembly: AssemblyTrademark("")] | |||
[assembly: AssemblyCulture("")] | |||
|
|||
// Setting ComVisible to false makes the types in this assembly not visible | |||
// to COM components. If you need to access a type in this assembly from | |||
// COM, set the ComVisible attribute to true on that type. | |||
[assembly: ComVisible(false)] | |||
|
|||
// The following GUID is for the ID of the typelib if this project is exposed to COM | |||
[assembly: Guid("4fc6aa61-ea96-4c57-9340-0284ca5a916b")] | |||
|
|||
// Version information for an assembly consists of the following four values: | |||
// | |||
// Major Version | |||
// Minor Version | |||
// Build Number | |||
// Revision | |||
// | |||
// You can specify all the values or you can default the Build and Revision Numbers | |||
// by using the '*' as shown below: | |||
// [assembly: AssemblyVersion("1.0.*")] | |||
[assembly: AssemblyVersion("1.0.0.0")] | |||
[assembly: AssemblyFileVersion("1.0.0.0")] |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,23 @@ | |||
h1. App Pool Recycle | |||
|
|||
Command line tool for recycling app pools on local and remote server's | |||
|
|||
h1. Example | |||
|
|||
The syntax is | |||
|
|||
<pre> | |||
apr [app pool name] [remote server name (optional)] | |||
<pre> | |||
|
|||
so to recycle the app pool foo on server bar you would do | |||
|
|||
<pre> | |||
apr foo bar | |||
</pre> | |||
|
|||
to recycle the app pool foo on your local computer you would just do | |||
|
|||
<pre> | |||
apr foo | |||
</pre> |