Skip to content

Instantly share code, notes, and snippets.

@logicbomb
Created June 15, 2012 04:04
Show Gist options
  • Select an option

  • Save logicbomb/2934619 to your computer and use it in GitHub Desktop.

Select an option

Save logicbomb/2934619 to your computer and use it in GitHub Desktop.
using System;
using System.Net;
using System.Threading;
using Lemur.Foundation.Logging;
using Microsoft.WindowsAzure.ServiceRuntime;
using log4net.Config;
namespace LemurMVP.AzureRuntime
{
public class WorkerRoleEntryPoint : RoleEntryPoint, ILoggingSource
{
private AzureServiceHost _host;
public WorkerRoleEntryPoint()
{
NServiceBus.SetLoggingLibrary.Log4Net(XmlConfigurator.Configure);
}
public override bool OnStart()
{
ServicePointManager.DefaultConnectionLimit = 12;
this.WriteDebugMessage("Configuring AzureServiceHost");
try
{
_host = new AzureServiceHost();
_host.Configure();
this.WriteInfoMessage("AzureServiceHost Configured");
return true;
}
catch (ServiceHostNotConfiguredException e)
{
this.WriteFatalMessage("Could not configure AzureServiceHost", e);
return false;
}
catch (Exception e)
{
this.WriteFatalMessage("Unable to start AzureServiceHost", e);
throw;
}
}
public override void OnStop()
{
_host.Stop();
this.WriteInfoMessage("AzureServiceHost Stopped");
}
public override void Run()
{
try
{
_host.Start();
this.WriteInfoMessage("AzureServiceHost Started");
Thread.Sleep(Timeout.Infinite);
}
catch (Exception e)
{
this.WriteFatalMessage("An unhandled exception was thrown by the AzureServiceHost", e);
throw;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment