mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Allow logging of output to syslog or /tmp/postgres.log.
Put all configurable parameters near top of file. Remove explicit path to postmaster executable. More comments.
This commit is contained in:
@ -2,19 +2,24 @@
|
|||||||
#
|
#
|
||||||
# postgres.init Start postgres back end system.
|
# postgres.init Start postgres back end system.
|
||||||
#
|
#
|
||||||
# Author: Thomas Lockhart <Thomas.Lockhart@jpl.nasa.gov>
|
# Author: Thomas Lockhart <lockhart@alumni.caltech.edu>
|
||||||
# based on news startup by David Myers
|
# modified from other startup files in the RedHat Linux distribution
|
||||||
#
|
#
|
||||||
# Written for RedHat Linux but should apply to other Linux distributions.
|
# This version can log backend output through syslog using the local5 facility.
|
||||||
#
|
# To enable this, edit /etc/syslog.conf to include a line similar to:
|
||||||
# To be installed as /etc/rc.d/init.d/postgres.init
|
# local5.* /var/log/postgres
|
||||||
# Softlink into rc5.d to bring up with multiuser and networking:
|
# and then set USE_SYSLOG to "yes" below
|
||||||
# cd /etc/rc.d/rc5.d; ln -s ../init.d/postgres.init S98postgres
|
|
||||||
#
|
|
||||||
# Assumptions:
|
|
||||||
# - the postgres user is named "postgres"
|
|
||||||
# - the postgres user is running csh/tcsh
|
|
||||||
#
|
#
|
||||||
|
#PGBIN="/opt/postgres/current/bin" # not used
|
||||||
|
PGACCOUNT="postgres" # the postgres account (you called it something else?)
|
||||||
|
POSTMASTER="postmaster" # this probably won't change
|
||||||
|
|
||||||
|
USE_SYSLOG="yes" # "yes" to enable syslog, "no" to go to /tmp/postgres.log
|
||||||
|
FACILITY="local5" # can assign local0-local7 as the facility for logging
|
||||||
|
PGLOGFILE="/tmp/postgres.log" # only used if syslog is disabled
|
||||||
|
|
||||||
|
PGOPTS="-B 256"
|
||||||
|
#PGOPTS="-i -B 256" # -i to enable TCP/IP rather than Unix socket
|
||||||
|
|
||||||
# Source function library.
|
# Source function library.
|
||||||
. /etc/rc.d/init.d/functions
|
. /etc/rc.d/init.d/functions
|
||||||
@ -29,36 +34,41 @@ then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ -f /opt/postgres/current/bin/postmaster ] || exit 0
|
#[ -f ${PGBIN}/${POSTMASTER} ] || exit 0
|
||||||
|
|
||||||
# See how we were called.
|
# See how we were called.
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
echo -n "Starting postgres service: "
|
if [ -f ${PGLOGFILE} ]
|
||||||
# force full login to get path names and environment variables
|
then
|
||||||
# postgres runs tcsh so use proper syntax in redirection
|
mv ${PGLOGFILE} ${PGLOGFILE}.old
|
||||||
# change this line if the postgres superuser account is not "postgres"
|
fi
|
||||||
# change this line if another shell syntax is necessary
|
echo -n "Starting postgres: "
|
||||||
# su - postgres -c 'postmaster -S' > /dev/null&
|
# force full login to get path names
|
||||||
su - postgres -c 'postmaster >>&! /tmp/postmaster.log&' > /dev/null&
|
# my postgres runs tcsh so use proper syntax in redirection...
|
||||||
|
if [ ${USE_SYSLOG} = "yes" ]; then
|
||||||
|
su - ${PGACCOUNT} -c "(${POSTMASTER} ${PGOPTS} |& logger -p ${FACILITY}.notice) &" > /dev/null&
|
||||||
|
else
|
||||||
|
su - ${PGACCOUNT} -c "${POSTMASTER} ${PGOPTS} >>&! ${PGLOGFILE} &" > /dev/null&
|
||||||
|
fi
|
||||||
sleep 5
|
sleep 5
|
||||||
pid=`pidof postmaster`
|
pid=`pidof ${POSTMASTER}`
|
||||||
echo -n "postmaster [$pid]"
|
echo -n "${POSTMASTER} [$pid]"
|
||||||
# touch /var/lock/subsys/postmaster
|
# touch /var/lock/subsys/${POSTMASTER}
|
||||||
echo
|
echo
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
echo -n "Stopping postgres service: "
|
echo -n "Stopping postgres: "
|
||||||
pid=`pidof postmaster`
|
pid=`pidof ${POSTMASTER}`
|
||||||
if [ "$pid" != "" ] ; then
|
if [ "$pid" != "" ] ; then
|
||||||
echo -n "postmaster [$pid]"
|
echo -n "${POSTMASTER} [$pid]"
|
||||||
kill -TERM $pid
|
kill -TERM $pid
|
||||||
sleep 1
|
sleep 1
|
||||||
fi
|
fi
|
||||||
echo
|
echo
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Usage: postgres.init {start|stop}"
|
echo "Usage: $0 {start|stop}"
|
||||||
exit 1
|
exit 1
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user