Greetings Friends,
I wanted to take a moment and let everyone know that a new version of Topshelf is just around the corner. The big feature that I want to take a moment to talk about is something that we have been calling ‘Shelving.’ What this basically allows you to do is xcopy deploy services.
What does this mean?
Well now Topshelf ships with a ‘host’ (Topshelf.Host.exe) that can be used to ‘host’ multiple services. When you install the host (Topshelf.Host.exe /install) or just run it, you should see a ‘Services’ directory appear in the folder it is running in.

Inside of this directory you can now place any number of services, each one should be housed in its own folder. The name of the folder is used to drive many specific conventions. If you look inside the default build of Topshelf you will see a folder named ‘clock’.

Looking inside the ‘clock’ folder we see:

The first thing to notice is the ‘clock.config’ this is the config file for your services app domain. Each folder/service gets its own app domain and in this way we can keep everyone safe and give everyone their own config setup.
Currently the config file tells us which class to call to Bootstrap the service, but we hope to have that happen automatically after we release this all official like.
If you have used Topshelf before then the bootstrapper will look quite familiar:
public class AShelvedClock : Bootstrapper<TheClock>
{
public void InitializeHostedService(IServiceConfigurator<TheClock> cfg)
{
cfg.HowToBuildService(n => new TheClock());
cfg.WhenStarted(s =>
{
XmlConfigurator.Configure(new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, “clock.log4net.config”)));
s.Start();
});
cfg.WhenStopped(s => s.Stop());
}
}
Which is basically just reusing the existing Topshelf configuration DSL.
UPDATE: My buddy Travis makes a good comment that we need to use ‘AppDomain.CurrentDomain.BaseDirectory’ here to get to our log4net configuration. If you try to use the ‘.’ notation in your path it ends up looking in the bin directory for the ‘topshelf.host.exe’ instead of your service folder. Thanks Travis!
So this is dandy and all, but what really makes this sparkle for me is that, once the host is running it can detect any changes to a given ‘service’ and restart it automatically. Just like IIS.

I think this is pretty cool. And is going to be the foundation for what I assume will be some sort of MassTransit Service Grid product in the future.
Well, I am not sure there is much more to say other than to ask you to pull it down from github, and tell me what you think! Key things that I still need to finish are removing some duplicate code, and then to ensure there is a clean shut down of services, and hopefully improving the logging.
hit me up on twitter @drusellers with your thoughts.
-d