Search code examples
c#windowswindows-servicestopshelf

Is there a graceful way to restart a Topshelf service daily, nightly, or on a schedule?


The title says it all. I couldn't find anything in their docs or on the web that met my needs.


Solution

  • Not really. Doing it via the service manager in the service will leave you in a bad state, since the service won't shutdown right or it will without any process left running to say start back up. This limitation isn't really a Topshelf limitation.

    You can use the recovery options and have a timer the exits the process on a given schedule; this is a bit weird but I believe people are doing it now.

    Lastly, you can create a monitoring service or job that interacts with the service manager, calling restart.