0

I have a server program which should run full time a day. If I want to change some parameters of it, Is there any way rather than shut down then restart way?

Treper
  • 3,539
  • 2
  • 26
  • 48
  • 2
    You should ask the author of the program. – Jon Apr 11 '12 at 07:08
  • Depends entirely on the design of the server program. A dirty way is to have it respond to some otherwise unused signal (SIGHUP maybe?) by reloading a settings file. – BoBTFish Apr 11 '12 at 07:09
  • It seems to be highly dependent on the server implementation. It must be written the way, which allows to modify parameters dynamically. – Alex Apr 11 '12 at 07:09
  • Set up several servers, and restart them one at a time. :-) – Bo Persson Apr 11 '12 at 07:11

2 Answers2

4

There are quite a few ways of doing this, including, but almost certainly not limited to:

  1. You can maintain the parameters in a separate file so that the program will periodically check that file and update its internal information.

  2. Similar to (1) but you can send some sort of signal to the application to get it to immediately re-read the file.

  3. You can do either (1) or (2) but using shared memory rather than a configuration file.

  4. You can have your program sit at the server end of an IPC conversation, so that a client can open up a connection to it to provide new parameters. Anything from a simple message queue to a full-blown HTTP server and associated pages.

Of course, all of these tend to need a fair amount of work in your program to get it to look for the new information.

You should take that into account when making your decision. By far the quickest solution to implement is to just (cleanly) kill off the process at something like 11:55pm then immediately restart it. It's simpler because your code probably already has the ability to load the information on startup, so this could be a simple cron one-liner.

Some people speak of laziness as a bad thing but that's not always the case :-)

paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953
  • + 1 This is not lazy. It is a considerate solution which harms no one, also buys the developers time to implement a hard solution (if it is really needed) in the time it takes, rather than chasing bugs on a live system. – daramarak Apr 11 '12 at 07:25
0

If the Server maintains many alive connections from clients, restarting the server process is the last way you should consider. Except reloading configuration files, inserting a proxy process between clients and server can be another way.

The proxy process is Responsible for 2 things.

a. Maintaining the connection from clients and forwarding packets to Server for handling.

b. Judging weather the current server process(Server A) is alive and if it not, switching to another server(Server B) automatically.

Then you can change parameters by restart server without worrying about interrupting clients since there is always two(or more) servers running.

tyger
  • 181
  • 4