Skip to content

This repository holds an example template structure for creating a notification worker service in .NET Core that runs as Windows Service or a Linux Daemon

Notifications You must be signed in to change notification settings

sangeethnandakumar/Express-Notification-Service-Template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

Express-Notification-Service-Template

Enable Console out only while Debugging

console out on a Windows Service can create errors espcly while using ColorfulConsole

var hasConsoleOut = configuration.GetSection("EnableConsoleOut").Get<bool>();
if(hasConsoleOut)
{
     Console.Clear();
     ConsoleHeader();
     ConsoleInfo();
     QueueList();
}

To Run As A Windows Service

Install these nuGet libraries

Microsoft.Extensions.Hosting
Microsoft.Extensions.Hosting.WindowsServices

Add UseWindowsService(); on program.cs

Host.CreateDefaultBuilder(args)
     .UseSerilog((hostingContext, loggerConfiguration) => loggerConfiguration.ReadFrom.Configuration(hostingContext.Configuration))
     .ConfigureServices((hostContext, services) =>
     {
         services.AddHostedService<Worker>();
         services.AddSingleton<IMessagingQueue, MessagingQueue>();
         services.AddSingleton<IConsoleDataProvider, ConsoleDataProvider>();
     }).UseWindowsService();

Now Release Mode => Build

Powershell To Install Service

Open powershell and execute the command to install service on Windows Machines

sc.exe create <NameOfService> binpath= C:\test\service.exe start= auto

Powershell To UnInstall Service

Open powershell and execute the command to install service on Windows Machines

STOP Service first & execute the command

sc.exe delete <NameOfService>

About

This repository holds an example template structure for creating a notification worker service in .NET Core that runs as Windows Service or a Linux Daemon

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages