postgres init script things solved
От | Claudiu Balciza |
---|---|
Тема | postgres init script things solved |
Дата | |
Msg-id | 01bd61fe$d95118c0$0300010a@claudiu обсуждение исходный текст |
Ответы |
Re: [HACKERS] postgres init script things solved
|
Список | pgsql-hackers |
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
Вложения
В списке pgsql-hackers по дате отправления: