Code Monkey home page Code Monkey logo

betterhostedservices's People

Contributors

geewee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

betterhostedservices's Issues

Question about default logging on service crash

Question : The current default implementation of CriticalBackgroundService.OnError log to the console. Is this a design choice ?

I'm using your library in one of my windows service application (from a worker service) and a few days ago it crashed. In my log file, I only had "INFO ... Microsoft.Hosting.Lifetime - Application is shutting down...". No reason why. From the lines before the shutdown, I could guess that it crashed during an operation inside the CriticalBackgroundService and no log/exception was written.
I found out that the CriticalBackgroundService.OnError will not log to an ILogger, but to the console. Obviously the console is not redirected to my log file. I'm using Microsoft ILogger, and my ILogger is configured to output to log4net, which log to a file and also the console.
I could think that you're using console because you're targetting a basic program, without any ilogger and all the DI stuff. However that can't be the case because you're already registering your services with the microsoft DI in the readme file and the HostedService you're trying to fix are from asp.net / worker.


I've implemented the virtual OnError in all my background service to log to my ILogger, so i'm fine with the rest and I don't require any modification from your part. I was kinda not expecting it to log to console, but instead to log to ILogger by default.

Is it by design that CriticalBackgroundService log to console, while PeriodicTaskRunnerBackgroundService use the ILogger facility ?

When I check the rest of your project, PeriodicTaskRunnerBackgroundService seems to use ILogger to report crash, but CriticalBackgroundService only use the console. Perhaps it's because it's critical ?

Re-enable tests for Windows and MacOS

For some reason tests that work fine on Linux fails on Windows - and I can't figure out whether or not it's due to the tests being broken, or platform differenes.

End process *less* gracefully

Describe the feature

It'd be nice if there was an option to end the process less gracefully as opposed to IHostApplicationLifetime.StopApplication()

But.... why?

In my scenario, I'm trying to apply this to a Windows service, which has recovery options in the event of a service failure. In my case specifically I want Windows to restart the service (after a short delay) when it encounters an exception. When implementing this packages as-is, it fails successfully in a way that the recovery options don't trigger.

To be honest I'm not sure exactly the best way to proceed. I'm not sure if using a non-zero exit code would help. I can run some tests tomorrow to see what options are available.

This site seems to suggest that a non-zero exit code won't trigger this, but it was written in 2008 so maybe things have changed. https://mdenomy.wordpress.com/2008/02/28/using-the-automatic-recovery-features-of-windows-services/

PS nice work! I really like the simplicity and I'm glad someone put a workaround in place until 6.0 (hopefully) adds the stop-on-exception feature that this addresses.

Packages on release instead push

Question

Maybe better create NuGet and GitHub packages on release, instead of pushing to main? It will prevent packages with potentially useless changes

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.