Skip to content
/ Topper Public
forked from rebus-org/Topper

🎩 Simple Windows Service helper (Topshelf-based, Azure Web Job capable)

License

Notifications You must be signed in to change notification settings

hopla/Topper

Repository files navigation

Topper

install from nuget

Generic Windows service host.

Based on Topshelf. Exposes a drastically simplified API based on IDisposable.

Getting started

Create YourNewAwesomeWindowsService as a Console Application project targeting at least .NET 4.5.2.

Include the NuGet package 📦

Install-Package Topper -ProjectName YourNewAwesomeWindowsService

and clean up your Program.cs so it becomes nice like this: 🌻

namespace YourNewAwesomeWindowsService
{
    class Program
    {
        static void Main()
        {
            
        }
    }
}

and then you configure Topper by going

var configuration = new ServiceConfiguration()
	.Add(.. function that returns an IDisposable ..)
	.Add(.. another function that returns an IDisposable ..);

ServiceHost.Run(configuration);

in Main, which could look like this:

namespace YourNewAwesomeWindowsService
{
    class Program
    {
        static void Main()
        {
            var configuration = new ServiceConfiguration()
                .Add(() => new MyNewAwesomeService());

            ServiceHost.Run(configuration);                
        }
    }
}

🐵 Easy!

Topper uses LibLog ⚡ to log things. If you want to use Serilog, you probably want to

Install-Package Serilog.Sinks.ColoredConsole -ProjectName YourNewAwesomeWindowsService

and configure the global 🌍 logger before starting your service:

namespace YourNewAwesomeWindowsService
{
    class Program
    {
        static void Main()
        {
            Log.Logger = new LoggerConfiguration()
                .WriteTo.ColoredConsole()
                .CreateLogger();

            var configuration = new ServiceConfiguration()
                .Add(() => new MyNewAwesomeService());

            ServiceHost.Run(configuration);                
        }
    }
}

And that is how you use Topper.


About

🎩 Simple Windows Service helper (Topshelf-based, Azure Web Job capable)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 91.3%
  • Batchfile 8.7%