3 # chkconfig: 2345 98 02
4 # description: PostgreSQL RDBMS
6 # This is an example of a start/stop script for SysV-style init, such
7 # as is used on Linux systems. You should edit some of the variables
8 # and maybe the 'echo' commands.
10 # Place this file at /etc/init.d/postgresql (or
11 # /etc/rc.d/init.d/postgresql) and make symlinks to
12 # /etc/rc.d/rc0.d/K02postgresql
13 # /etc/rc.d/rc1.d/K02postgresql
14 # /etc/rc.d/rc2.d/K02postgresql
15 # /etc/rc.d/rc3.d/S98postgresql
16 # /etc/rc.d/rc4.d/S98postgresql
17 # /etc/rc.d/rc5.d/S98postgresql
18 # Or, if you have chkconfig, simply:
19 # chkconfig --add postgresql
21 # Proper init scripts on Linux systems normally require setting lock
22 # and pid files under /var/run as well as reacting to network
23 # settings, so you should treat this with care.
25 # Original author: Ryan Kirkpatrick <pgsql@rkirkpat.net>
27 # $PostgreSQL: pgsql/contrib/start-scripts/linux,v 1.11 2010/02/23 22:15:35 momjian Exp $
32 prefix=/usr/local/pgsql
35 PGDATA="/usr/local/pgsql/data"
37 # Who to run the postmaster as, usually "postgres". (NOT "root")
40 # Where to keep a log file
41 PGLOG="$PGDATA/serverlog"
43 # It's often a good idea to protect the postmaster from being killed by the
44 # OOM killer (which will tend to preferentially kill the postmaster because
45 # of the way it accounts for shared memory). Setting the OOM_ADJ value to
46 # -17 will disable OOM kill altogether. If you enable this, you probably want
47 # to compile PostgreSQL with "-DLINUX_OOM_ADJ=0", so that individual backends
48 # can still be killed by the OOM killer.
53 # The path that is to be used for the script
54 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
56 # What to use to start up the postmaster. (If you want the script to wait
57 # until the server has started, you could use "pg_ctl start -w" here.
58 # But without -w, pg_ctl adds no value.)
59 DAEMON="$prefix/bin/postmaster"
61 # What to use to shut down the postmaster
62 PGCTL="$prefix/bin/pg_ctl"
66 # Only start if we can find the postmaster.
69 echo "$DAEMON not found"
77 # Parse command line parameters.
80 echo -n "Starting PostgreSQL: "
81 test x"$OOM_ADJ" != x && echo "$OOM_ADJ" > /proc/self/oom_adj
82 su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1
86 echo -n "Stopping PostgreSQL: "
87 su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast"
91 echo -n "Restarting PostgreSQL: "
92 su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast -w"
93 test x"$OOM_ADJ" != x && echo "$OOM_ADJ" > /proc/self/oom_adj
94 su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1
98 echo -n "Reload PostgreSQL: "
99 su - $PGUSER -c "$PGCTL reload -D '$PGDATA' -s"
103 su - $PGUSER -c "$PGCTL status -D '$PGDATA'"
107 echo "Usage: $0 {start|stop|restart|reload|status}" 1>&2