Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1932d92

Browse files
author
Thomas G. Lockhart
committed
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.
1 parentd358456 commit1932d92

File tree

1 file changed

+37
-27
lines changed

1 file changed

+37
-27
lines changed

‎contrib/linux/postgres.init

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
1-
#!/bin/sh
1+
#!/bin/sh
22
#
33
# postgres.init Start postgres back end system.
44
#
5-
# Author: Thomas Lockhart <Thomas.Lockhart@jpl.nasa.gov>
6-
#based on news startupby David Myers
5+
# Author: Thomas Lockhart <lockhart@alumni.caltech.edu>
6+
#modified from other startupfiles in the RedHat Linux distribution
77
#
8-
# Written for RedHat Linux but should apply to other Linux distributions.
9-
#
10-
# To be installed as /etc/rc.d/init.d/postgres.init
11-
# Softlink into rc5.d to bring up with multiuser and networking:
12-
# cd /etc/rc.d/rc5.d; ln -s ../init.d/postgres.init S98postgres
13-
#
14-
# Assumptions:
15-
# - the postgres user is named "postgres"
16-
# - the postgres user is running csh/tcsh
8+
# This version can log backend output through syslog using the local5 facility.
9+
# To enable this, edit /etc/syslog.conf to include a line similar to:
10+
# local5.* /var/log/postgres
11+
# and then set USE_SYSLOG to "yes" below
1712
#
13+
#PGBIN="/opt/postgres/current/bin"# not used
14+
PGACCOUNT="postgres"# the postgres account (you called it something else?)
15+
POSTMASTER="postmaster"# this probably won't change
16+
17+
USE_SYSLOG="yes"# "yes" to enable syslog, "no" to go to /tmp/postgres.log
18+
FACILITY="local5"# can assign local0-local7 as the facility for logging
19+
PGLOGFILE="/tmp/postgres.log"# only used if syslog is disabled
20+
21+
PGOPTS="-B 256"
22+
#PGOPTS="-i -B 256"# -i to enable TCP/IP rather than Unix socket
1823

1924
# Source function library.
2025
. /etc/rc.d/init.d/functions
@@ -29,36 +34,41 @@ then
2934
exit 0
3035
fi
3136

32-
[-f/opt/postgres/current/bin/postmaster ]||exit 0
37+
#[ -f${PGBIN}/${POSTMASTER} ] || exit 0
3338

3439
# See how we were called.
3540
case"$1"in
3641
start)
37-
echo -n"Starting postgres service:"
38-
# force full login to get path names and environment variables
39-
# postgres runs tcsh so use proper syntax in redirection
40-
# change this line if the postgres superuser account is not "postgres"
41-
# change this line if another shell syntax is necessary
42-
#su - postgres -c 'postmaster -S' > /dev/null&
43-
su - postgres -c'postmaster >>&! /tmp/postmaster.log&'> /dev/null&
42+
if [-f${PGLOGFILE} ]
43+
then
44+
mv${PGLOGFILE}${PGLOGFILE}.old
45+
fi
46+
echo -n"Starting postgres:"
47+
# force full login to get path names
48+
# my postgres runs tcsh so use proper syntax in redirection...
49+
if [${USE_SYSLOG}="yes" ];then
50+
su -${PGACCOUNT} -c"(${POSTMASTER}${PGOPTS} |& logger -p${FACILITY}.notice) &"> /dev/null&
51+
else
52+
su -${PGACCOUNT} -c"${POSTMASTER}${PGOPTS} >>&!${PGLOGFILE} &"> /dev/null&
53+
fi
4454
sleep 5
45-
pid=`pidofpostmaster`
46-
echo -n"postmaster [$pid]"
47-
#touch /var/lock/subsys/postmaster
55+
pid=`pidof${POSTMASTER}`
56+
echo -n"${POSTMASTER} [$pid]"
57+
#touch /var/lock/subsys/${POSTMASTER}
4858
echo
4959
;;
5060
stop)
51-
echo -n"Stopping postgres service:"
52-
pid=`pidofpostmaster`
61+
echo -n"Stopping postgres:"
62+
pid=`pidof${POSTMASTER}`
5363
if ["$pid"!="" ];then
54-
echo -n"postmaster [$pid]"
64+
echo -n"${POSTMASTER} [$pid]"
5565
kill -TERM$pid
5666
sleep 1
5767
fi
5868
echo
5969
;;
6070
*)
61-
echo"Usage:postgres.init {start|stop}"
71+
echo"Usage:$0 {start|stop}"
6272
exit 1
6373
esac
6474

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp