A questiontion about commandbox servcie manager. I...
# box-products
b
A questiontion about commandbox servcie manager. If you stop the windows service, is the cf instance immediately stopped when the stop command returns? Or does it take a while for the instance to stop?
b
In my experience with NSSM and the CB service manager, the windows service is just a mechanism for issuing start and stop commands. It doesn't actually care or know what the current state of the underlying server is when it does thatโ€ฆ it just fires the command and forgets. So, noโ€ฆ the actual server is not fully stopped/started just because the windows service reports that it's done (the only thing it's done with is running the command)
b
@birdy1980 Bobby is correct and that's just how Windows service work. Stop commands are basically async.
b
Cool, thanks
๐Ÿ‘ 1
Then I'll build a check to see if the CFserver is really stopped
b
If you are in a situation where you really need to do that, you might just update the start command in the service to "stop && start --console" or, if you are on commandbox 5.5.2+, you can just do a status check instead. "status && start --console". I'm stuck with NSSM for the most part right now and updating from "start --console" to "stop && start --console" AND adding an environment variable to set box_config_nonInteractiveShell to true solved the issues I was having with the service getting out of sync with the actual server. That said, none of that was necessary on the latest commandbox and service manager combination... just upgrading both to the latest got rid of any issues I was having with it.
b
@birdy1980 Are you trying to restart the service?
Generally speaking, you can just sleep a few seconds and run the service start. if the server is still shutting down, it will just keep trying until it works ๐Ÿ™‚
Combining this with your other question about
server info
, I'm guessing you're trying to write something to detect when the server is actually stopped. If so, check out the
--json
and
property
flags as they will give you machine parsable output
Copy code
server info --json
or even better...
Copy code
server info property=status
b
@bdw429s I'm not trying to restart the service. I want to stop the service, make sure it is stopped, then empty out some temp folders, update the application. (If the CF is not stopped it might lock some of the files I'm trying to delete/update)
b
Fair enough, my suggestion above still stands however on how to get the status programtically
b
I 'm already utilizing the property argument to get the status and server home directory ๐Ÿ™‚
And the commandbox service manager is really good stuf. ๐Ÿ‘
๐Ÿ‘ 2
Makes the job real easy ๐Ÿ™‚
b
yeah... I'm still trying to get approval on more licenses. It's hard when I've solved the NSSM problems though. package-scripting the service setup alone is enough to make me want it lol
definitely better than NSSM though