Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Created app pool recycle command line tool

  • Loading branch information...
commit 29c4ae110ab9617f69c03cabb9e2b88dd1473aa0 0 parents
@jhollingworth authored
7 .gitignore
@@ -0,0 +1,7 @@
+.svn/entries
+.svn
+AppPoolRecycle.5.1.ReSharper
+bin
+obj
+*Resharper
+__ReSharper.AppPoolRecycle
23 AppPoolRecycle.5.1.ReSharper.user
@@ -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>
20 AppPoolRecycle.sln
@@ -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
BIN  AppPoolRecycle.suo
Binary file not shown
65 AppPoolRecycle/AppPoolRecycle.csproj
@@ -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>
5 AppPoolRecycle/AppPoolRecycle.csproj.user
@@ -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>
28 AppPoolRecycle/AppPoolRecycleCommand.cs
@@ -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);
+ }
+ }
+}
46 AppPoolRecycle/AppPoolRecycleConfig.cs
@@ -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)]"; }
+ }
+ }
+}
23 AppPoolRecycle/Program.cs
@@ -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;
+ }
+ }
+ }
+}
36 AppPoolRecycle/Properties/AssemblyInfo.cs
@@ -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")]
BIN  apr.exe
Binary file not shown
BIN  lib/Microsoft.Web.Administration.dll
Binary file not shown
23 readme.textile
@@ -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>
Please sign in to comment.
Something went wrong with that request. Please try again.