Mission Critical Community Server Background Tasks

Community Server background tasks are great and I’ve created a lot of them.  There’s one thing about background tasks that can cause problems, however.  When the website process stops so do all of its background tasks.

I was designing a task today on my Community Server-based Jobs Management Application that for several good reasons needs to run once each day at 11:00 PM.  The site is used heavily during business hours, but it mostly sits idle during off-hours.  With the IIS site going inactive in the evening for potentially hours at a time, my 11:00 PM task had little chance of success.

The solution was to keep the website active and all of its background processes running.  I wanted to use my old friend WebMon, but with the site being behind a firewall and NT Authentication-based, WebMon couldn’t do the job for me.

The skinny of it is that I created a KeepAlive.aspx page in Community Server and an .EXE to load the page every 15 minutes.   The .EXE console source is below.  Not much to it.

 

The KeepAlive.aspx page, if loaded and viewed in a browser would look like this.  I’m writing a Community Server message in it just to give it something to do.  Inheriting from CSThemePage takes care of all of the Community Server theming.

To monitor the effectiveness of the Keep Alive utility I write to the Community Server Event Log when I ping the site, shown here in the KeepAlive.aspx.cs CodeBehind. 

 

This is where the geeky beauty of today’s coding comes into play.  Check out the event log below on my development server after performing a command line Keep Alive ping.  The website had stopped seven hours earlier (event 13859).  The Keep Alive .EXE wakes up the site, 2 seconds later the Keep Alive event is logged.  I configured the .EXE in Scheduler on the Production Server to ping the site every 15 minutes between 5:00 PM and 12:00 AM.

With The Keep Alive agent running I can now be confident that any mission critical Community Server background tasks will perform the way I need them to perform. 

Article written by

A long time developer, I was an early adopter of Linux in the mid-90's for a few years until I entered corporate environments and worked with Microsoft technologies like ASP, then .NET. In 2008 I released Sueetie, an Online Community Platform built in .NET. In late 2012 I returned to my Linux roots and locked in on Java development. Much of my work is available on GitHub.