DotNetNuke keep alive service in Windows Powershell

I was recently required to provide a solution for a DotNetNuke keep alive service. There are many solutions available within the community, a free version exists called DNN monitor (http://www.dnnmonitor.com/) which seems to provide an excellent service (or that is what the benefits of the service suggests!).

The requirement for the above is to prevent ASP.NET releasing the resources when the DNN site has been idle, which would require the site to be recompiled and loaded again which will create an initial delay. The keep alive service will keep the application pool alive during idle periods and therefore help to optimise performance.

This solution was to be a tempoary workaround until a monitoring application was to be installed, which in turn by actively monitoring the website will prevent ASP.NET releasing the resources due to the site being idle.

This was compiled using Windows Powershell and initialising an instance of the .NET WebClient class. The keep alive service will need to run every 10 minutes, so I will invoke the script block in a loop while the condition is set to be ‘true’ and use the Start-Sleep cmdlet to suspend the script block for a period of 10 minutes (10*60).

The process of keeping the application pool alive is handled by specifying the keep alive ASPX page to be downloaded as a specified string using the ‘WebClient.DownloadString.Method’. In this instance the host header is ‘www.domain.local’ and the keepalive.aspx file is located in the virtual directory ‘dnn’.

While ($true)
{
$WebClient = New-Object Net.WebClient
$WebClient.DownloadString(“https://www.domain.local/dnn/keepalive.aspx”)
Sleep -Seconds (10*60)
}

The above may be invoked using task scheduler to run at startup, can be run as a background job from a logged on session or the powershell script could be wrapped up as a windows service .

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s