aspose file tools*
The moose likes General Computing and the fly likes How to Control service shutdown sequence Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » General Computing
Bookmark "How to Control service shutdown sequence " Watch "How to Control service shutdown sequence " New topic
Author

How to Control service shutdown sequence

vivekkumar sharma
Ranch Hand

Joined: Dec 21, 2005
Posts: 70
I am running three java applications say A,B,C as windows services with A having dependency on B and B having dependency on C.

Which means when you start A, It shall automatically start service B and C (Java programs running). And also when you stop C ,it shall stop first B and then A.

Problem I am facing is when you stop C, windows first stop A then B.

I am able to register java applications as windows services with dependency but problem is when u stop service, Windows send signal to all the dependent services to stop and thus I am not able to control order in which services stop

Help is appreciated
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41816
    
  62
This seems to be more of a Windows issue than a Java issue, so I'm moving this thread to "General Computing".


Ping & DNS - my free Android networking tools app
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
Originally posted by vivekkumar sharma:
And also when you stop C ,it shall stop first B and then A.

Problem I am facing is when you stop C, windows first stop A then B.

Actually in this case I agree with Windows' actions. Given the dependecies you have specified an orderly shutdown sequence is A, then B, then C. Stopping C before either A or B pulls the rug out under A and B. Maybe you need to explain why you want a different shutdown sequence.

Based on the way you defined the dependencies the Service Control Manager will actually start C, then B and then finally A when you try to start A.
[ March 29, 2006: Message edited by: Peer Reynders ]
vivekkumar sharma
Ranch Hand

Joined: Dec 21, 2005
Posts: 70
Hi
Thans for replying.
I want to control the shut down sequence of services because
say C is client
B is Child server
A is Master Server

now when you Close Master Server
I want Child server should NOT shut down before client service shuts.

Bt setting dependenices as follows
Client Dependent on Child Server and Master Server
Child server dependent on Master Server.

winodws does not gurrante shut down sequence of Child server and client

regards
vivek
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
Originally posted by vivekkumar sharma:
Bt setting dependenices as follows
Client Dependent on Child Server and Master Server
Child server dependent on Master Server.


If the "Child Server" can operate without the "Master Server" then its not truly "dependent" - look into an alternate way of starting the "Master Server" i.e. not through dependencies. You could always declare a dependency for the "Child Server" to another late starting service like the spooler - that should give the Master Server long enough to start up.

However if the client shuts down quickly enough it may be enough to increase the "Kill timeout" How to Increase Shutdown Time for Services to Close Properly. The SCM gives a service only 20 seconds by default to shut down - after that the service is forcibly terminated.
vivekkumar sharma
Ranch Hand

Joined: Dec 21, 2005
Posts: 70
Thanks for your pointers
I will try solution
 
jQuery in Action, 2nd edition
 
subject: How to Control service shutdown sequence