An open API service indexing awesome lists of open source software.

https://github.com/sangeethnandakumar/express-notification-service-template

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
https://github.com/sangeethnandakumar/express-notification-service-template

console dotnet-core linux-deamon notification-service windows-service worker-service

Last synced: about 1 year ago
JSON representation

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

Awesome Lists containing this project

README

          

# Express-Notification-Service-Template

## Enable Console out only while Debugging
console out on a Windows Service can create errors espcly while using ColorfulConsole
```csharp
var hasConsoleOut = configuration.GetSection("EnableConsoleOut").Get();
if(hasConsoleOut)
{
Console.Clear();
ConsoleHeader();
ConsoleInfo();
QueueList();
}
```

## To Run As A Windows Service
Install these nuGet libraries
```nuget
Microsoft.Extensions.Hosting
Microsoft.Extensions.Hosting.WindowsServices
```

Add UseWindowsService(); on program.cs
```csharp
Host.CreateDefaultBuilder(args)
.UseSerilog((hostingContext, loggerConfiguration) => loggerConfiguration.ReadFrom.Configuration(hostingContext.Configuration))
.ConfigureServices((hostContext, services) =>
{
services.AddHostedService();
services.AddSingleton();
services.AddSingleton();
}).UseWindowsService();
```

### Now Release Mode => Build

## Powershell To Install Service
Open powershell and execute the command to install service on Windows Machines
```powershell
sc.exe create 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
```powershell
sc.exe delete
```