Thread: postgres init script things solved
The postgresql-?.?.?/contrib/linux/postgres.init is meant to start your postmaster at boot time and stop it at halt/reboot. Excelent. But it is made for postgres account running tcsh. I know nothing about tchs and my postgres account defaults to bash. So (thanks to Steve "Stevers!" Coile) I changed it to bash: ----------------------------------------------------- if [ ${USE_SYSLOG} = "yes" ]; then su - ${PGACCOUNT} -c "(${POSTMASTER} ${PGOPTS} 2>&1 | logger -p ${FACILITY}.notice) &" > /dev/null 2>&1 & else su - ${PGACCOUNT} -c "${POSTMASTER} ${PGOPTS} 2>>&1 ${PGLOGFILE} &" > /dev/null 2>&1 & fi ----------------------------------------------------- cool, but there was another problem. The script wouldn't stop the postmaster at halt/reboot while it worked just fine if manually invoked. (RedHat 5.0 sysV init) Meanwhile I leafed some shell programming book and things cleared up a bit. In the /etc/rc.d/rc file (the one to start/stop services), the 'stop' branch, there is a section meant to check if subsystems are up. ----------------------------------------------------- # Check if the subsystem is already up. subsys=${i#/etc/rc.d/rc$runlevel.d/K??} [ ! -f /var/lock/subsys/$subsys ] && \ [ ! -f /var/lock/subsys/${subsys}.init ] && continue ----------------------------------------------------- That's it, if there's no file named exactly after the symlink (without K??) in /var/lock/subsys, then it decides the subsystem is not up and gracefully exits. If you look in /etc/rc.d/init.d/postgres.init (copy of postgresql-?.?.?/contrib/linux/postgres.init), you'll find: ----------------------------------------------------- # touch /var/lock/subsys/${POSTMASTER} ----------------------------------------------------- which is equally commented and wrong for that kind of init. It should be: ----------------------------------------------------- # use the name of the symlink without [KS]?? touch /var/lock/subsys/postgres ----------------------------------------------------- I use: K05postgres -> /etc/rc.d/init.d/postgres.init on runlevel 1 K05postgres -> /etc/rc.d/init.d/postgres.init on runlevel 6 S98postgres -> /etc/rc.d/init.d/postgres.init on runlevel 3 Claudiu
Attachment
Applied. > > This is a multi-part message in MIME format. > > ------=_NextPart_000_0087_01BD6217.FE9E50C0 > Content-Type: text/plain; > charset="iso-8859-1" > Content-Transfer-Encoding: 7bit > > The postgresql-?.?.?/contrib/linux/postgres.init is meant to start your > postmaster at boot time and stop it at halt/reboot. Excelent. > But it is made for postgres account running tcsh. I know nothing about tchs > and my postgres account defaults to bash. So (thanks to Steve "Stevers!" > Coile) I changed it to bash: > ----------------------------------------------------- > if [ ${USE_SYSLOG} = "yes" ]; then > > su - ${PGACCOUNT} -c "(${POSTMASTER} ${PGOPTS} 2>&1 | logger -p > ${FACILITY}.notice) &" > /dev/null 2>&1 & > > else > > su - ${PGACCOUNT} -c "${POSTMASTER} ${PGOPTS} 2>>&1 ${PGLOGFILE} &" > > /dev/null 2>&1 & > > fi -- Bruce Momjian | 830 Blythe Avenue maillist@candle.pha.pa.us | Drexel Hill, Pennsylvania 19026 + If your life is a hard drive, | (610) 353-9879(w) + Christ can be your backup. | (610) 853-3000(h)
> > The postgresql-?.?.?/contrib/linux/postgres.init is meant to start your > > postmaster at boot time and stop it at halt/reboot. Excelent. > > But it is made for postgres account running tcsh. I know nothing about tchs > > and my postgres account defaults to bash. So (thanks to Steve "Stevers!" > > Coile) I changed it to bash: OK, but _I_ don't run bash. So someone else is now maintaining this file? Why didn't we keep both forms in the file, with one commented out? What are we trying to accomplish here?? - Tom
On Mon, 27 Apr 1998, Thomas G. Lockhart wrote: > > > The postgresql-?.?.?/contrib/linux/postgres.init is meant to start your > > > postmaster at boot time and stop it at halt/reboot. Excelent. > > > But it is made for postgres account running tcsh. I know nothing about tchs > > > and my postgres account defaults to bash. So (thanks to Steve "Stevers!" > > > Coile) I changed it to bash: > > OK, but _I_ don't run bash. So someone else is now maintaining this > file? Why didn't we keep both forms in the file, with one commented out? > What are we trying to accomplish here?? Why not do what most init scripts do and use the standard /bin/sh?
> > > > The postgresql-?.?.?/contrib/linux/postgres.init is meant to start your > > > postmaster at boot time and stop it at halt/reboot. Excelent. > > > But it is made for postgres account running tcsh. I know nothing about tchs > > > and my postgres account defaults to bash. So (thanks to Steve "Stevers!" > > > Coile) I changed it to bash: > > OK, but _I_ don't run bash. So someone else is now maintaining this > file? Why didn't we keep both forms in the file, with one commented out? > What are we trying to accomplish here?? bash/sh is the standard, expecially because the top of the file has #!/bin/sh. -- Bruce Momjian | 830 Blythe Avenue maillist@candle.pha.pa.us | Drexel Hill, Pennsylvania 19026 + If your life is a hard drive, | (610) 353-9879(w) + Christ can be your backup. | (610) 853-3000(h)
> > > > The postgresql-?.?.?/contrib/linux/postgres.init is meant to start your > > > > postmaster at boot time and stop it at halt/reboot. Excelent. > > > > But it is made for postgres account running tcsh. I know nothing about tchs > > > > and my postgres account defaults to bash. So (thanks to Steve "Stevers!" > > > > Coile) I changed it to bash: > > > > OK, but _I_ don't run bash. So someone else is now maintaining this > > file? Why didn't we keep both forms in the file, with one commented out? > > What are we trying to accomplish here?? > > bash/sh is the standard, expecially because the top of the file has > #!/bin/sh. Sorry, the top of the init script and the postgres shell aren't related. The init script is run at startup out of the root account. The line which was changed is run under the postgres account, which can have a different shell from the root shell. imho it is not a step forward to break some code to help others. How about asking the person submitting the patch to document what they did differently? The original code at least had a line saying what had to be changed; the patch doesn't fix the comment or suggest how to support an alternate shell. Or, have two files in contrib, postgres.init.tcsh and postgres.init. Or at least something which is a step forward rather than sideways... - Tom
> about asking the person submitting the patch to document what they did > differently? The original code at least had a line saying what had to be > changed; the patch doesn't fix the comment or suggest how to support an > alternate shell. > > Or, have two files in contrib, postgres.init.tcsh and postgres.init. Or > at least something which is a step forward rather than sideways... Ok, now have two files. -- Bruce Momjian | 830 Blythe Avenue maillist@candle.pha.pa.us | Drexel Hill, Pennsylvania 19026 + If your life is a hard drive, | (610) 353-9879(w) + Christ can be your backup. | (610) 853-3000(h)