Self Hosted (Windows Service), SSL & Performance Questions

1,484 views
Skip to first unread message

PaulC

unread,
May 25, 2012, 3:45:49 PM5/25/12
to servic...@googlegroups.com
We were hoping to find some answers to the following questions before diving head-first into ServiceStack ...
 
- We did not find the documentation on the ServiceStack Windows Service application (or Self-Hosting). It would be helpful if someone could point us to these details.
- How will the self-hosted option scale for high simulaneous usage?
- Has anyone implemented SSL support with a self-hosted implementation? Just wondering if this is possible?
 
Thanks,
Paul

Demis Bellot

unread,
May 25, 2012, 3:57:35 PM5/25/12
to servic...@googlegroups.com
Hi Paul,

We did not find the documentation on the ServiceStack Windows Service application (or Self-Hosting). It would be helpful if someone could point us to these details.

Here are some starter templates of different popular ServiceStack configurations. ConsoleAppHost and WinServiceAppHost are self-hosting using HttpListener:

Here's an example of how to convert a self-hosting HttpListener host to an ASP.NET host so you can see the differences between the 2:

How will the self-hosted option scale for high simulaneous usage?

It doesn't create any new threads and just executes services on HttpListener's IO thread callbacks, so should work well for non-CPU intensive services, tho you would need to benchmark.

Has anyone implemented SSL support with a self-hosted implementation? Just wondering if this is possible?

ServiceStack's self-host just uses HttpListener so you would need to setup a certificate for that:

Cheers,

aph5

unread,
Jun 21, 2012, 4:30:09 PM6/21/12
to servic...@googlegroups.com
Hi,

I have implemented a sample windows service using TopShelf. But I have got a problem. When I start the service it stops... Could you take a look at my source code, please? ( I had putted the Thread.Sleep(Timeout.Infinite), but it seems not working )

public class Program
    {
        static void Main(string[] args)
        {
           LogManager.LogFactory = new NLogFactory();
           ILog Log = LogManager.GetLogger(typeof(Program));

            var appSettings = new AppSettings();

            var host = HostFactory.New(x =>
            {
                x.Service<ServerAppHost>(s =>
                {
                    s.SetServiceName("OfferUploader");
                    s.ConstructUsing(name => new ServerAppHost());
                    s.WhenStarted(tc =>
                                      {
                                          Log.Info("Starting service...");
                                          tc.Init();
                                          tc.Start(appSettings.Get("ServiceUrl", "http://localhost:8095"));
                                      });

                    s.WhenStopped(tc => 
                    { 
                        Log.Info("Stopping service...");
                        tc.Stop();
                        Log.Info("Done.");
                    });
                });

                x.RunAsLocalSystem();

                x.SetDescription("OfferUploaderService");
                x.SetDisplayName("OfferUploader");
                x.SetServiceName("OfferUploader");
            });
             
            host.Run();
            Thread.Sleep(Timeout.Infinite);

Demis Bellot

unread,
Jun 22, 2012, 5:55:18 AM6/22/12
to servic...@googlegroups.com
Hi,

This doesn't look like ServiceStack code and I'm unfamiliar with TopShelf so I can't comment on its correct usage.

See the WinServiceAppHost template for an example of hosting ServiceStack in a windows service:

Hosting in a WinService requires inheriting from AppHostHttpListenerBase, and Thread.Sleep(Timeout.Infinite); is only required when debugging where you run the host as a console host for debugging (avoiding the WinService). I usually will wrap this in #defines as seen in:

Reply all
Reply to author
Forward
0 new messages