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
- Host: GitHub
- URL: https://github.com/sangeethnandakumar/express-notification-service-template
- Owner: sangeethnandakumar
- Created: 2020-08-09T08:19:46.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-10-10T17:24:05.000Z (over 5 years ago)
- Last Synced: 2025-02-09T11:12:38.935Z (over 1 year ago)
- Topics: console, dotnet-core, linux-deamon, notification-service, windows-service, worker-service
- Language: C#
- Homepage:
- Size: 16.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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
```