-
Notifications
You must be signed in to change notification settings - Fork 149
Added parameter to control if the service starts immediately when installing #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added parameter to control if the service starts immediately when installing #55
Conversation
|
How weird. I've just been working on something to try and achieve the same outcome. My solution was just adding another action so you would do "MyService action:delayedinstall" to get it to just install the service. I see you've gone down the parameter route. For yours, would you have to do "MyService action:install startimmediately:true" ? |
|
Yeah, true would be the default, so action:install startimmediately:false would be the same as your action:delayedinstall. |
|
Hi guys, just looking at this now. It definitely should be a part of this lib if you found a sensible use-case for it. It's just a matter of choosing the best syntax for it as both this and #56 have pretty much the same functionality. I am slightly inclining towards the solution by @avisonmaher as it seems a bit more verbose and won't require and extra parameter. What do you think guys? Any reasons come to mind why we should use one or another? |
|
Hey, when I implemented this, I just looked at the underlying calls to the service and saw that there was an extra paramerter, that was always set to true, so I added one to forward this functionality. I don't really see a reason to favor one over the other. They both provide the same functionality, "delayedinstall" is maybe not the best name, but tbh I can't really think of a better one. |
|
I don't mind, I'd agree "delayedinstall" isn't the best name. Taking inspiration from https://ss64.com/nt/sc.html it could be changed to "create". |
PeterKottas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few small things
|
|
||
| public string DisplayName { get; set; } | ||
|
|
||
| public bool? StartImmediately { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please change this to not nullable and add default property value?
| cred, | ||
| autoStart: true, | ||
| startImmediately: true, | ||
| startImmediately: config.StartImmediately ?? true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it's nullable it should be config.StartImmediately.HasValue ? config.StartImmediately.Value : true instead. But I think it's better to make it non nullable like mentioned in my previous comment.
| ConfigureService(innerConfig); | ||
|
|
||
| return 0; | ||
| return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seems to be a lot of false positive diffs because of formatting changes. Just some extra white spaces I guess. Could you please reformat this doc?
|
Ok I'll be merging this one in guys. Just a few small issues with the code so please @fhofmann could you take a look? I'll be merging in and releasing right after this is done. |
|
Thanks for the review. |
|
Cheers mate, all good. There's still some formatting issues even after this commit but screw that. I'll fix those myself and this PR is ok to go in as far as I am concerned. |
|
I've tried this by adding both: MyWindowsService startimmediately:false action:install (as discussed in here) and tried swapping the parameters around: MyWindowsService action:install startimmediately:false But it isn't working, it is installing the service and running it straight away. |
|
For me it works fine: action:install start-immediately:true |
|
One thing I noticed, the message being displayed might be miss leading when using action:install and start-imediately:false "Successfully registered and started service" will be written to the console. |
Added a parameter to control the startImmediately behaviour of the win32 service when installing the service.
This is useful when installing, then configuring something, and then starting the service after this configuration step is done.
Default is the same as before.