Topshelf service/app stuck at “Creating”
Question
I'm trying to start up an instance of Topshelf. I've downloaded the binaries for v. 2.3 and extracted everything.
Then I've created an empty console application. I've changed the framework to .NET 4.0 framework
and added the following code to my static void Main()
method:
Host h = HostFactory.New(x =>
{
x.Service< MyApp>(s =>
{
s.SetServiceName("Something");
s.ConstructUsing(name => new MyApp());
s.WhenStarted(tc => tc.Start());
s.WhenStopped(tc => tc.Stop());
});
x.RunAsLocalSystem();
x.SetDescription("Something");
x.SetDisplayName("Something");
x.SetServiceName("Something");
});
h.Run();
The consoleapp runs as expected when I hit F5.
I then copied the bin/release output to a topshelf/services/test directory and run Topshelf.Host.exe. This is the result:
If I point my browser to the dashboard, this is what I see:
The "test" service keeps saying "Creating" (waited for over 15 minutes).
What am I doing wrong? I've tried with multiple kind of console apps. If I call install
on my console app, the app gets registered successfully.
Thanks in advance!
Solution
When you link the Topshelf DLL into your console application, you should run your console application from the command line. From what I can see about, you're trying to use the Topshelf Host instead. Try running your console application and you should see it start your service correctly.