On 1/19/06, Matt Goodall
Hi,
I have a couple of services. The second is dependent on the first being fully initialised before the second gets set up.
<snip>
In other words, what is the recommended way of starting services in the
correct order, including waiting for them to get initialised fully, these days?
I actually wrote something like this today, a subclass of MultiService, because my main service was dependant on there being no other services running on the same machine, and I had to implement a PB client/server to ask the other instance to shut down. This is mostly because Windows sucks, and doesn't allow me to just do a "kill <pid>" on the old one, but gave me an excuse to start the PB integration of my app. I just subclassed MultiService and reimplemented startService and stopService appropriately, not chaining my sub-service starts until I was certain I had managed to start my own service, and not stopping my service until my sub-services had stopped. It's a fairly simple idiom, so it's probably pretty easy to implement yourself, but I'm surprised a generic one hasn't been written yet. Similarly I've had to write a new LoopingService that runs a "setup" callable before looping the main service, and also has a "minimum wait between calls" timer going on it. None of these have been particulalrly difficult.