clarsen@lbl.gov (Case Larsen) (05/23/91)
A nice thing about SunOS is that it pages directly from the file. The business of updating and restarting a server process that is constantly running on many machines is made simpler by noticing that when a process attempts to page from a newer image than it was started with, it dies. A shell script that restarts the server again after it dies can be used to automatically restart the server after updates. E.g. #!/bin/csh /etc/server-process exec $0 In my case, the server is a database process and updates are done by copying over the newly compiled program and broadcasting a query to all the database servers. The process starts to get "unblocked" because of the availability of data for read, but gets aborted and restarted because the disk image changed. This beats rsh $i 'ps agx | egrep server-process | \ some-ugly-awk-kill-script-I-forget| sh' and is faster. -- Case Larsen clarsen@lbl.gov -- ;; Case Larsen ;; Email: clarsen@lbl.gov
okunewck@psuvax1.cs.psu.edu (Phil OKunewick) (05/23/91)
clarsen@lbl.gov (Case Larsen) writes: > ...A shell script that restarts the server again after it >dies can be used to automatically restart the server after updates. >E.g. >#!/bin/csh >/etc/server-process >exec $0 Ah, a supervisory process. That works, but I like this one better: ] #!/bin/sh ] while : ] do ] { insert your favorite process here } ] done The supervisor here never restarts; it just loops forever. This may be less overhead. We'll let you decide that one. Perhaps one could trap SIGTERM to make the process self-restarting; not sure. Does Sun send a SIGTERM or a SIGKILL? Or does it just drop the process cold without a signal? A fun way to do an endless loop: boolean Hell_Freezes_Over = FALSE; Repeat { blah } Until Hell_Freezes_Over; I suppose there about a zillion different "fun" boolean variable names. I hope this doesn't start a thread on them. (But if you must post your favorite, don't forget to tack on the ObHack.) ObHack: Back on a DecSystem-20 years ago, it was popular to use everybody else's command files. (These were sort of a cross between aliases and shell scripts.) Somebody else always had a nifty routine that made your life easier, but they also regularly threw in one or two surprises for you as well. Now, I have a code of ethics when it comes to practical jokes: It must do no damage, and the victim should be able to look back on it afterwards and laugh. But hopefully the gag will blow their mind for a few minutes in the process. (True, this one's a variation on a much nastier prank. But mine version is harmless, anticipates the victim more, and is more of a hack than many of the recent postings without any hacks at all in them.) My favorite command-file surprise was a little ditty I called "wash". If you prompted for more info, all it said was "(directory)". Should the victim go ahead and try it, it would go through the motions of erasing all his files and exiting (or so it seemed). In reality it did nothing; it just printed a bunch of official-looking nonsense and sat there waiting for the user to type in his next (now panicky) command. Naturally this next command would be a directory listing ("Shit!! Did that really happen??") so _whatever_command_he_typed_in_ would produce a bogus listing of an empty directory. At this point the process would actually exit, leaving a very panicky (though completely unharmed) victim. (If the luser did a second directory listing, he would become enlightened.) Six months later, I ran into a very frazzled and upset friend of mine outside the computer building. It seems he'd just spent some time on the phone with the console operator, who had told him that he'd have to go through a bunch of official red tape to get his files restored. It took me a minute to realize what he was talking about. When I asked him if he'd done a second directory listing, he looked puzzled for a moment, then started to smile... Jim Moody - if you're out there, howdy! (A nasty contemporary version of this is to create a file called "*" in their home directory, then let nature take its course. But this isn't very creative, it does a lot of damage, and if you must do this sort of thing to entertain yourself then you should really consider getting a life instead.)
jgabriel@mtecv2.mty.itesm.mx (Ing. J. Gabriel Ruiz P.) (05/25/91)
okunewck@psuvax1.cs.psu.edu (Phil OKunewick) writes: clarsen@lbl.gov (Case Larsen) writes: > E.g. > #!/bin/csh > /etc/server-process > exec $0 >> Ah, a supervisory process. That works, but I like this one better: >> ] #!/bin/sh >> ] while : >> ] do >> ] { insert your favorite process here } >> ] done Bot options work fine with normal server programs, but what happens if the server program is a deamon, this is, the server program goes to background when is runned? Example: #!/bin/sh while : do /usr/local/bin/ircd -x1 # run the IRC server done The ircd program runs in background, then the while loop runs again even the ircd program don't ends. Somebody knows an option to do the same thing, with this kind of programs? -- Juan Gabriel Ruiz Pinto Internet: Ing. Sistemas Electronicos jgabriel@mtecv2.mty.itesm.mx I.T.E.S.M. Campus Monterrey