Starting the service after installation

3,102 views
Skip to first unread message

flipdoubt

unread,
May 25, 2011, 12:30:25 PM5/25/11
to topshelf-discuss
I can get my service installed and registered to start automatically,
but I cannot figure out how to programmatically start my service after
installation. All the user has to do is go to the Service panel and
click start (yay!), but you know how those users are ... I have tried
HostConfigurator.StartAutomatically(), but it does not start the
service. I have tried shelling the executable like so, but the Status
column is always black in the Services panel:

x.AfterInstall(
() =>
Process.Start(
Assembly.GetAssembly(typeof
(Program)).CodeBase).StartInfo.CreateNoWindow = true);

Any ideas?

Travis Smith

unread,
May 25, 2011, 12:43:31 PM5/25/11
to topshelf...@googlegroups.com
StartAutomatically is on restarts. I think there's an issue for having
an "install and start" option at the command line but I don't know how
to use it yet. Chris could chime in on that.
(https://github.com/Topshelf/Topshelf/issues/25)

Regardless, after executing <cmd> install, you can always do net start
<service name>.

-Travis

Chris Patterson

unread,
May 25, 2011, 12:53:35 PM5/25/11
to topshelf...@googlegroups.com
Just add start to the install command line:

myservice install start

And it will start immediately after it installs the service.

flipdoubt

unread,
May 25, 2011, 12:57:20 PM5/25/11
to topshelf-discuss
Undocumented APIs!

On May 25, 12:53 pm, Chris Patterson <ch...@phatboyg.com> wrote:
> Just add start to the install command line:
>
> myservice install start
>
> And it will start immediately after it installs the service.
>
> On Wed, May 25, 2011 at 11:43 AM, Travis Smith <tra...@legomaster.net>wrote:
>
>
>
>
>
>
>
> > StartAutomatically is on restarts. I think there's an issue for having
> > an "install and start" option at the command line but I don't know how
> > to use it yet. Chris could chime in on that.
> > (https://github.com/Topshelf/Topshelf/issues/25)
>
> > Regardless, after executing <cmd> install, you can always do net start
> > <service name>.
>
> > -Travis
>

Travis Smith

unread,
May 25, 2011, 12:59:42 PM5/25/11
to topshelf...@googlegroups.com
https://github.com/Topshelf/Topshelf/wiki

You're welcomed to document it for us :) But you are correct. We
aren't the best at this as we should be.

-Travis

flipdoubt

unread,
May 25, 2011, 1:49:32 PM5/25/11
to topshelf-discuss
Done.

I was really kidding because "undocumented APIs" are often in the news
due to Apple, but here they are welcome.

Thanks for the tip, Chris, and thanks to everyone for the project as a
whole.

John Simons

unread,
May 25, 2011, 5:22:38 PM5/25/11
to topshelf...@googlegroups.com
Actually it is well documented, see the help:


From: flipdoubt <d.s...@ceoimage.com>
To: topshelf-discuss <topshelf...@googlegroups.com>
Sent: Thursday, 26 May 2011 2:57 AM
Subject: [topshelf-discuss] Re: Starting the service after installation

flipdoubt

unread,
May 26, 2011, 3:42:16 PM5/26/11
to topshelf-discuss
Er, thanks. Not to sound unappreciative but ... Houston definitely has
a problem if you have to dig into three documentation pages to find
the one with the help you are looking for. Maybe there is some
bifurcation or trifurcation going on here, because I made my
"undocumented API" non-humorous joke while using
http://topshelf-project.com/documentation/command-line-syntax/ as my
source for documentation, then I was encouraged to update the docs at
https://github.com/Topshelf/Topshelf/wiki/Command-Line (which I did),
but now I am told I should have been looking at
https://github.com/Topshelf/Topshelf/blob/master/src/Topshelf/HelpText.txt
to begin with.

So ... which one should I be looking at or updating? Am I looking at
two different projects? I am trying to be helpful by saying too many
sources of documentation make it hard for TopShelf neophytes, like me,
learn about TopShelf.

Regardless, I still enjoy using TopShelf.


On May 25, 5:22 pm, John Simons <johnsimons...@yahoo.com.au> wrote:
> Actually it is well documented, see the help:https://github.com/Topshelf/Topshelf/blob/master/src/Topshelf/HelpTex...
>
> ________________________________
> From: flipdoubt <d.sm...@ceoimage.com>

Dru Sellers

unread,
May 26, 2011, 3:48:17 PM5/26/11
to topshelf...@googlegroups.com
the above mentioned help text will show up if you type 'help' at the command line.

-d

flipdoubt

unread,
May 26, 2011, 3:54:47 PM5/26/11
to topshelf-discuss
Yeah, I now know that, but, as a meta-example, the "help" switch is
not documented at either of the two other command-line reference URLs
I mentioned. In this case, too much help is not helpful. But I do
appreciate the help I'm getting up here on the discussion boards,
pointing me to competing help pages.

Thanks for the help. D'oh!


On May 26, 3:48 pm, Dru Sellers <d...@drusellers.com> wrote:
> the above mentioned help text will show up if you type 'help' at the command
> line.
>
> -d
>
>
>
>
>
>
>
> On Thu, May 26, 2011 at 2:42 PM, flipdoubt <d.sm...@ceoimage.com> wrote:
> > Er, thanks. Not to sound unappreciative but ... Houston definitely has
> > a problem if you have to dig into three documentation pages to find
> > the one with the help you are looking for. Maybe there is some
> > bifurcation or trifurcation going on here, because I made my
> > "undocumented API" non-humorous joke while using
> >http://topshelf-project.com/documentation/command-line-syntax/as my
> > source for documentation, then I was encouraged to update the docs at
> >https://github.com/Topshelf/Topshelf/wiki/Command-Line(which I did),
> > but now I am told I should have been looking at
> >https://github.com/Topshelf/Topshelf/blob/master/src/Topshelf/HelpTex...

John Simons

unread,
May 26, 2011, 5:41:10 PM5/26/11
to topshelf...@googlegroups.com
Agree, the help is not in sync everywhere.
But regarding the "help" switch, I thought it is very very common for apps to have either:
help, -?, ?, -h

At the moment TopShelf only supports: help and  --help
I think is not a bad idea to also support: -?, ?, -h, -help, is this possible?

Let me know your thoughts, and I'll create a patch for it.

Cheers
John


From: flipdoubt <d.s...@ceoimage.com>
To: topshelf-discuss <topshelf...@googlegroups.com>
Sent: Friday, 27 May 2011 5:54 AM

flipdoubt

unread,
May 26, 2011, 6:05:12 PM5/26/11
to topshelf-discuss
Sure, any/all of those options would help. But is http://topshelf-project.com
a different project from https://github.com/Topshelf/Topshelf? I
downloaded the bits from Nuget. Are those bits supplied by this same
project?

Call me not geeky enough, but I saw the command-line docs online and
assumed those were the only docs without considering embedded help.
Because it is *my* executable, I had my Main method check the command-
line args for "help", show its own help, and exit. I only used
HostFactory when the command-line did not contain "help". I have now
changed it to show TopShelf's embedded help without showing any of my
own.

On May 26, 5:41 pm, John Simons <johnsimons...@yahoo.com.au> wrote:
> Agree, the help is not in sync everywhere.
> But regarding the "help" switch, I thought it is very very common for apps to have either:
> help, -?, ?, -h
>
> At the moment TopShelf only supports: help and  --help
> I think is not a bad idea to also support: -?, ?, -h, -help, is this possible?
>
> Let me know your thoughts, and I'll create a patch for it.
>
> Cheers
> John
>
> ________________________________
> From: flipdoubt <d.sm...@ceoimage.com>
> To: topshelf-discuss <topshelf...@googlegroups.com>
> Sent: Friday, 27 May 2011 5:54 AM
> Subject: [topshelf-discuss] Re: Starting the service after installation
>
> Yeah, I now know that, but, as a meta-example, the "help" switch is
> not documented at either of the two other command-line reference URLs
> I mentioned. In this case, too much help is not helpful. But I do
> appreciate the help I'm getting up here on the discussion boards,
> pointing me to competing help pages.
>
> Thanks for the help. D'oh!
>
> On May 26, 3:48 pm, Dru Sellers <d...@drusellers.com> wrote:
>
>
>
> > the above mentioned help text will show up if you type 'help' at the command
> > line.
>
> > -d
>
> > On Thu, May 26, 2011 at 2:42 PM, flipdoubt <d.sm...@ceoimage.com> wrote:
> > > Er, thanks. Not to sound unappreciative but ... Houston definitely has
> > > a problem if you have to dig into three documentation pages to find
> > > the one with the help you are looking for. Maybe there is some
> > > bifurcation or trifurcation going on here, because I made my
> > > "undocumented API" non-humorous joke while using
> > >http://topshelf-project.com/documentation/command-line-syntax/asmy
> > > source for documentation, then I was encouraged to update the docs at
> > >https://github.com/Topshelf/Topshelf/wiki/Command-Line(whichI did),

Travis Smith

unread,
May 27, 2011, 7:31:10 AM5/27/11
to topshelf...@googlegroups.com
Topshelf-project.com and github.com/Topshelf/Topshelf are the same
project. The download link on topshelf-project.com takes you the
github page. There is a disconnect, and it's something we are aware of
and will continue to work on.

The help isn't obvious, perhaps it's something we can make more clear
as well. Or perhaps a "AlwaysShowHelp()" configuration option when you
use the console runner.

-Travis

flipdoubt

unread,
May 27, 2011, 7:52:34 AM5/27/11
to topshelf-discuss
AlwaysShowHelp() sounds good. So does a PrependToHelpText(string text)
method so I can add my app's help text to TopShelf's. I originally
developed my project as a stand-alone executable with its own help
text and then turned it into a service using TopShelf which, correct
me if I am wrong, is one of your use cases. TopShelf is cool, but it
is really just a tool within my project, so it seems natural that my
help would supersede TopShelf's help. PrependToHelpText would be one
way to combine the two.

Travis Smith

unread,
May 27, 2011, 7:55:07 AM5/27/11
to topshelf...@googlegroups.com
Stick it in an issue on github.com/topshelf/topshelf/issues and we'll
get to it. Failing to do that will likely mean we'll forget about.

-Travis

Dru Sellers

unread,
May 27, 2011, 9:16:26 AM5/27/11
to topshelf...@googlegroups.com
I think a good point has been made. it would really be nice to have a way for users to have their own help screen apart from ours. Kinda like

our users could hook into
service.exe help

and our help would be at

service.exe help --system

or something.

-d

flipdoubt

unread,
May 27, 2011, 11:21:39 AM5/27/11
to topshelf-discuss
Reply all
Reply to author
Forward
0 new messages