aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes How to stop the server gracefully? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "How to stop the server gracefully?" Watch "How to stop the server gracefully?" New topic
Author

How to stop the server gracefully?

James Du
Ranch Hand

Joined: Mar 23, 2001
Posts: 186
Hi.
I am always wondering these days how to stop the server gracefully.
I designed a DataServer that provides connections as request incomes from the client. I registered the DataServer to the RMIRegistry and it keep serving.
Now the problem arises when it comes to shutdown, How could i get reference of the DataServer instance again and invoke its shutdown method that could lock the database, unexport the remote objects, and then exit(0) cleanly?
The only method i know is to create a server side GUI that hold the DataServer instance as an instance variable while it's runing. therefore i could stop the server through the GUI as it started the server. I do not wish to design such a ServerGUI, nor do i want to use the ugly Ctrl+C. they all seemed too graceless. I prefer the commandline and it always seems professional.
I think it would be a typical problem, wondering why there are no posts concerning this?
How did you solved this? :roll:
Thanks in advance
James
[ April 04, 2002: Message edited by: James Du ]
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi James,
Well you could accept input from the server shell window. For example, if the user typed in "halt" you could then initiate a graceful shutdown ("halt" might not be a good choice on UNIX boxes if the server is started in the background). The only problem would be if you are dumping server status to the same shell, it might be confusing.
Hope this helps
Michael Morris


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

Or you could make a very simple GUI that has a button called Stop. But either way is fine.
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
James Du
Ranch Hand

Joined: Mar 23, 2001
Posts: 186
Thanks, Michael and Mark
I think accepting an input from the shell window sounds pretty good in both windows and unix shell. why i had not thought of it
The only problem would be if you are dumping server status to the same shell, it might be confusing

I am not quite familiar with unix platform, what does this mean? it's a must having the project tested in both windows and unix?
Regards
James
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi James,
What I meant was, ordinarily when a non-GUI server is running, you send info to the shell like: "Starting database", "Initiating RemoteFactory", etc. You might even send Exception info to the shell. If by some chance the user were entering a stop command at the same time output were going to the shell there might be some mixing of screen output. As for UNIX, the shell is a much more powerful device than for Windows. For instance, you can start a background process by ending a command line with &. For example, "java RemoteDataServer &" would start the java VM and immediately return to allow any other OS command to be entered from the same shell. It's sort of like "start java RemoteDataServer" in Windows except there is not a new shell created. Also, UNIX shells parse input for regular expressions in a much more robust fashion than Windows. You should probably assume that your assignment will ultimately be tested on a SOLARIS system which is Sun's flavor of UNIX. But if it works in a Windows shell, it should work fine in SOLARIS provided that you let it be known that the server should not run in the background.
As I said, "halt" is probably not a good command to stop the server in a UNIX environment since that is a system command which shuts down the system.
Hope this helps
Michael Morris
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to stop the server gracefully?