• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to stop the server gracefully?

 
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or you could make a very simple GUI that has a button called Stop. But either way is fine.
Mark
 
James Du
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic