Forum OpenACS Q&A: killing postgres while aolserver running

I installed the AOLserver restart script that is provided by the Installation Guide. It works fine.

I know that the aolserver restarts after you put a killall -9 nsd on him - that's what the script is for.

But what should I do, when I want to change the options for the startup of the postmaster? Is it healthy for postgres to kill its process while aolserver is running? If not, how do I deactivate the restart-script in order to shut down postgres right afterwards and restart it with new options?

And finally I followed these instructions from /contrib/linux/start-scripts/linux...

# This is an example of a start/stop script for SysV-style init, such # as is used on Linux systems. You should edit some of the variables
# and maybe the 'echo' commands.
#
# Place this file at /etc/init.d/postgresql (or
# /etc/rc.d/init.d/postgresql) and make symlinks to
# /etc/rc.d/rc0.d/K02postgresql
# /etc/rc.d/rc1.d/K02postgresql
# /etc/rc.d/rc2.d/K02postgresql
# /etc/rc.d/rc3.d/S98postgresql
# /etc/rc.d/rc4.d/S98postgresql
# /etc/rc.d/rc5.d/S98postgresql
# Or check out the chkconfig program, if you have it.
#
# Proper init scripts on Linux systems normally require setting lock
# and pid files under /var/run as well as reacting to network
# settings, so you should treat this with care.

But I got a "failed" while rebooting my box. I only set the symbolic links and did the copying to /etc/rc.d/init.d... Did I miss anything???

Thanks
Collapse
Posted by David Kuczek on
Okay,

solved that question, but have another one for you.

(It was a permission thing. Did a chmod 700 /etc/rc.d/init.d/postgres and chmod o+rx and chmod u+rx... It works now.)

What should I do, when I want to reboot my box? Shut down postgres first and then aolserver??? Or can I just do an init 6??? Well shutting down aolserver with the script running is still a part of my original question.

Thanks

Collapse
Posted by Don Baccus on
The best way to kill the postmaster is to use pg_ctl.  I kill it like this:

pg_ctl stop -m fast

this rolls back any transaction underway rather than let them complete, which is useful if you've accidently started the RDBMS off on a cross join of two large tables, etc.

I'm a stone-aged sysadmin myself, being too lazy to learn new tricks.  I just edit /etc/inittab, kill -TERM aolserver, then stop the postmaster, restart it, edit /etc/inittab and do a "telinit q".

Be careful, the "1" key is surprisingly near the "q" key.  I know someone who typed "telinit 1" by accident and ended up having to get the datacenter staff to reboot the server ...

All this is probably bad advice that will make up-to-date sysadmin types cringe, but that's how I do it.

Collapse
Posted by David Kuczek on
So it's not such a good idea to stop the postmaster while aolserver is running, is that correct?

But when I do a "killall -9 nsd" aolserver comes up again quicker than I can watch. (I have that restart-script installed). How do I make aolserver stop as long as I want it to and not restart immediately?

Collapse
Posted by Jonathan Ellis on
That's what Don was talking about editing /etc/inittab for; before you kill aolserver, comment out the nsd respawn line and run "telinit q" to get init to stop respawning nsd.  Then reverse your changes when you have finished kicking postgres.  (So you will need two "telinit q"s in there.)

When you are shutting down I don't think it will be an issue, because hopefully you don't have nsd set to respawn in runlevel 0. :)

Collapse
Posted by Mike Clark on
This works for me:

<your-path-to-aolserver>/bin/nsd -Kt <your-nsd-init-file.tcl> -u <your-nsd-admin-login>

Collapse
Posted by Mike Clark on
Oops. Hit submit too quickly, before I realized that David had an inittab entry. sorry.
Collapse
Posted by Vadim Nasardinov on

David Kuczek repeatedly said things like:

I have that restart-script installed

I have a sneaking suspicion you are referring to the Perl script restart-aolserver. That script has nothing to do with the fact that AOLserver restarts after you kill it. I would start by reading the inittab manual pages:

$ man inittab
Collapse
Posted by David Kuczek on
Oh I get it. Most of the time I am happy when everything is running. I just got 3.2.5 installed on a 7.1.1 with patch PG and it worked, so I didn't feel like diving into that aolserver-restart thing before watching Ally McBeal 😊

Thanks Vadim, but what did I get restart-aolserver.txt working for then if inittab does that job?

Collapse
Posted by Jonathan Ellis on
Look at the perl script.  Restart-aolserver actually kills the current nsd process; init notices this, and starts it again since you have a respawn line for it in /etc/inittab.  So the net effect is restarting even though the script should really be called "kill-aolserver."
Collapse
Posted by Vadim Nasardinov on
what did I get restart-aolserver.txt working for then if inittab does that job?

It saves you the trouble of running ps -ef | grep nsd and killing the process by hand (or killing some other process by accident when you mistype the process id.)