8
8
# This version can log backend output through syslog using the local5 facility.
9
9
# To enable this, edit /etc/syslog.conf to include a line similar to:
10
10
# local5.* /var/log/postgres
11
- # and then set USE_SYSLOG to "yes" below
11
+ # and then set USE_SYSLOG to "yes" and FACILITY to "local5" below
12
12
#
13
- # PGBIN="/opt/postgres/current/bin" # not used
13
+ # PGBIN="/opt/postgres/current/bin" # not used any more - thomas 1997-12-14
14
14
PGACCOUNT=" postgres" # the postgres account (you called it something else?)
15
15
POSTMASTER=" postmaster" # this probably won't change
16
16
17
+ USE_SOCKET=" yes" # "no" to disable Unix sockets on localhost
18
+ PGSOCKETFILE=" /tmp/.s.PGSQL.5432"
17
19
USE_SYSLOG=" yes" # "yes" to enable syslog, "no" to go to /tmp/postgres.log
18
20
FACILITY=" local5" # can assign local0-local7 as the facility for logging
19
21
PGLOGFILE=" /tmp/postgres.log" # only used if syslog is disabled
20
22
21
- PGOPTS=" -B 256"
22
- # PGOPTS="-i -B 256" # -i to enable TCP/IP rather than Unix socket
23
+ PGOPTS=" -i -B 1024" # -S -o '-Fe'"
24
+ if [ ${USE_SOCKET} = " no" ]
25
+ then
26
+ PGOPTS=" -i ${PGOPTS} " # -i to enable TCP/IP rather than Unix socket
27
+ fi
23
28
24
29
# Source function library.
25
30
. /etc/rc.d/init.d/functions
34
39
exit 0
35
40
fi
36
41
42
+ # Don't bother checking for file existance to avoid hardcoding any paths - thomas 1997-12-14
37
43
# [ -f ${PGBIN}/${POSTMASTER} ] || exit 0
38
44
39
45
# See how we were called.
40
46
case " $1 " in
41
47
start)
48
+ # force a stop to kill a running postmaster and to clean up sockets
49
+ # necessary if system crashed (a power outage provoked this feature)
50
+ eval $0 stop
51
+ # save the old log file, if any
42
52
if [ -f ${PGLOGFILE} ]
43
53
then
44
54
mv ${PGLOGFILE} ${PGLOGFILE} .old
45
55
fi
56
+
46
57
echo -n " Starting postgres: "
58
+
47
59
# force full login to get path names
48
- # my postgres runs SH/BASH so use proper syntax in redirection...
60
+ # my postgres runs tcsh so use proper syntax in redirection...
49
61
if [ ${USE_SYSLOG} = " yes" ]; then
50
- su - ${PGACCOUNT} -c " (${POSTMASTER} ${PGOPTS} 2>&1 | logger -p ${FACILITY} .notice) &" > /dev/null 2>&1 &
62
+ su - ${PGACCOUNT} -c " (${POSTMASTER} ${PGOPTS} |& logger -p ${FACILITY} .notice) &" > /dev/null&
51
63
else
52
- su - ${PGACCOUNT} -c " ${POSTMASTER} ${PGOPTS} 2 >>&1 ${PGLOGFILE} &" > /dev/null 2>&1 &
64
+ su - ${PGACCOUNT} -c " ${POSTMASTER} ${PGOPTS} >>&! ${PGLOGFILE} &" > /dev/null&
53
65
fi
54
66
sleep 5
55
67
pid=` pidof ${POSTMASTER} `
@@ -65,6 +77,10 @@ case "$1" in
65
77
kill -TERM $pid
66
78
sleep 1
67
79
fi
80
+ if [ ${USE_SOCKET} = " yes" ] && [ -S ${PGSOCKETFILE} ]; then
81
+ echo -n " (remove socket ${PGSOCKETFILE} )"
82
+ rm -f ${PGSOCKETFILE}
83
+ fi
68
84
echo
69
85
;;
70
86
* )
0 commit comments