简体   繁体   中英

Topshelf service/app stuck at “Creating”

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: Topshelf控制台输出

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM