Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i run a ServiceStack console project as a Windows Service?

I have create a ServiceStack console application that works great, but of course, I have to leave it running after triggering it from a command prompt. I want to run this as a Windows Service.

I'm reviewing this wiki page which states that you can run SS as a Windows Service.

https://github.com/ServiceStack/ServiceStack/wiki/Self-hosting

I was not totally clear on how to do this. This StarterTemplate is referenced from 2 years ago. Do I clone this project and then copy my code into it?

https://github.com/ServiceStack/ServiceStack.Examples/tree/master/src/StarterTemplates/WinServiceAppHost

like image 845
Shane Avatar asked Jun 19 '13 19:06

Shane


People also ask

Can I run a console app as a Windows service?

Customize Program. cs to support the functioning of both a console application and the windows service. Summary : If you install the application, it will work as a windows service and if you directly run it, it will behave as a console application.

How do you call a Windows service method in C#?

Choose "Visual C#" >> "Windows" project type and select "Windows Service" from the right hand side and name the project "TestWindowsService" as shown in the following screenshot. After you click "OK", the project will be created and you will see the design view of the service as shown in the following screen.


1 Answers

The easiest way is to create a ServiceStack Windows Service Empty project in ServiceStackVS VS.NET Extension.

Otherwise you can clone the WinService project, and create a new Windows Service project from Visual Studio and copy the approach in Program.cs.

A more recent ServiceStack Windows Service project is the Razor Rockstars website running in a Windows Service Host, the template of which was based on the ServiceStack.Examples Starter template.

like image 101
mythz Avatar answered Sep 30 '22 10:09

mythz