Skip to content

Instantly share code, notes, and snippets.

@mikeobrien
Created October 1, 2010 14:39
Show Gist options
  • Save mikeobrien/606294 to your computer and use it in GitHub Desktop.
Save mikeobrien/606294 to your computer and use it in GitHub Desktop.
public class Program
{
public static void Main(string[] args)
{
// ...
var loadmailConfig = RunnerConfigurator.New(x =>
{
x.ConfigureService<TimerController>(s =>
{
s.Named("DunderMifflinLoadmail");
s.HowToBuildService(name =>
new TimerController(name,
Registry.Current,
r => r.Resolve<Loadmail>().Run(),
Registry.Current.Resolve<IConfiguration>().Sendmail.Frequency,
logProvider));
s.WhenStarted(controller => controller.Start());
s.WhenStopped(controller => controller.Stop());
});
x.SetDescription("Queues mailings.");
x.SetDisplayName("DunderMifflin Loadmail");
x.SetServiceName("DunderMifflinLoadmail");
});
var sendmailConfig = RunnerConfigurator.New(x =>
{
x.ConfigureService<TimerController>(s =>
{
s.Named(serviceAlias);
s.HowToBuildService(name =>
new TimerController(string.Format("{0} ({1})", serviceAlias, serverId),
Registry.Current,
r => r.Resolve<Sendmail>().Run(serverId),
Registry.Current.Resolve<IConfiguration>().Sendmail.Frequency,
logProvider));
s.WhenStarted(controller => controller.Start());
s.WhenStopped(controller => controller.Stop());
});
x.SetDescription("Processes and sends mailings.");
x.SetDisplayName("DunderMifflin Sendmail");
x.SetServiceName(serviceAlias);
});
Runner.Host(??, args);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment