head	1.11;
access;
symbols
	REL9_0_0:1.11
	REL9_1_ALPHA1:1.11
	REL9_0_RC1:1.11
	REL9_0_BETA4:1.11
	REL9_0_STABLE:1.11.0.4
	REL9_0_BETA3:1.11
	REL9_0_BETA2:1.11
	REL7_4_29:1.5
	REL8_0_25:1.7
	REL8_1_21:1.7
	REL8_2_17:1.8
	REL8_3_11:1.8
	REL8_4_4:1.8
	REL9_0_BETA1:1.11
	REL9_0_ALPHA5_BRANCH:1.11.0.2
	REL9_0_ALPHA5:1.11
	REL7_4_28:1.5
	REL8_0_24:1.7
	REL8_1_20:1.7
	REL8_2_16:1.8
	REL8_3_10:1.8
	REL8_4_3:1.8
	REL9_0_ALPHA4:1.10
	REL9_0_ALPHA4_BRANCH:1.10.0.2
	REL8_5_ALPHA3:1.9
	REL8_5_ALPHA3_BRANCH:1.9.0.4
	REL7_4_27:1.5
	REL8_0_23:1.7
	REL8_1_19:1.7
	REL8_2_15:1.8
	REL8_3_9:1.8
	REL8_4_2:1.8
	REL8_5_ALPHA2:1.9
	REL8_5_ALPHA2_BRANCH:1.9.0.2
	REL7_4_26:1.5
	REL8_0_22:1.7
	REL8_1_18:1.7
	REL8_2_14:1.8
	REL8_3_8:1.8
	REL8_4_1:1.8
	REL8_5_ALPHA1:1.8
	REL8_5_ALPHA1_BRANCH:1.8.0.8
	REL8_4_STABLE:1.8.0.6
	REL8_4_0:1.8
	REL8_4_RC2:1.8
	REL8_4_RC1:1.8
	REL8_4_BETA2:1.8
	REL8_4_BETA1:1.8
	REL7_4_25:1.5
	REL8_0_21:1.7
	REL8_1_17:1.7
	REL8_2_13:1.8
	REL8_3_7:1.8
	REL7_4_24:1.5
	REL8_0_20:1.7
	REL8_1_16:1.7
	REL8_2_12:1.8
	REL8_3_6:1.8
	REL7_4_23:1.5
	REL8_0_19:1.7
	REL8_1_15:1.7
	REL8_2_11:1.8
	REL8_3_5:1.8
	REL7_4_22:1.5
	REL8_0_18:1.7
	REL8_1_14:1.7
	REL8_2_10:1.8
	REL8_3_4:1.8
	REL7_4_21:1.5
	REL8_0_17:1.7
	REL8_1_13:1.7
	REL8_2_9:1.8
	REL8_3_3:1.8
	REL7_4_20:1.5
	REL8_0_16:1.7
	REL8_1_12:1.7
	REL8_2_8:1.8
	REL8_3_2:1.8
	REL8_2_7:1.8
	REL8_3_1:1.8
	REL8_3_STABLE:1.8.0.4
	REL8_3_0:1.8
	REL8_3_RC2:1.8
	REL7_3_21:1.3
	REL7_4_19:1.5
	REL8_0_15:1.7
	REL8_1_11:1.7
	REL8_2_6:1.8
	REL8_3_RC1:1.8
	REL8_3_BETA4:1.8
	REL8_3_BETA3:1.8
	REL8_3_BETA2:1.8
	REL8_3_BETA1:1.8
	REL7_3_20:1.3
	REL7_4_18:1.5
	REL8_0_14:1.7
	REL8_1_10:1.7
	REL8_2_5:1.8
	REL7_3_19:1.3
	REL7_4_17:1.5
	REL8_0_13:1.7
	REL8_1_9:1.7
	REL8_2_4:1.8
	REL8_0_12:1.7
	REL8_1_8:1.7
	REL8_2_3:1.8
	REL7_3_18:1.3
	REL7_4_16:1.5
	REL8_0_11:1.7
	REL8_1_7:1.7
	REL8_2_2:1.8
	REL8_0_10:1.7
	REL8_1_6:1.7
	REL8_2_1:1.8
	REL7_4_15:1.5
	REL7_3_17:1.3
	REL8_2_STABLE:1.8.0.2
	REL8_2_0:1.8
	REL8_2_RC1:1.8
	REL8_2_BETA3:1.8
	REL8_2_BETA2:1.8
	REL8_1_5:1.7
	REL8_0_9:1.7
	REL7_4_14:1.5
	REL7_3_16:1.3
	REL8_2_BETA1:1.8
	REL7_3_15:1.3
	REL7_4_13:1.5
	REL8_0_8:1.7
	REL8_1_4:1.7
	REL7_3_14:1.3
	REL7_4_12:1.5
	REL8_0_7:1.7
	REL8_1_3:1.7
	REL7_3_13:1.3
	REL7_4_11:1.5
	REL8_0_6:1.7
	REL8_1_2:1.7
	REL7_3_12:1.3
	REL7_4_10:1.5
	REL8_0_5:1.7
	REL8_1_1:1.7
	REL8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1.2.0.2
	REL7_1:1.1;
locks; strict;
comment	@# @;


1.11
date	2010.02.23.22.15.35;	author momjian;	state Exp;
branches;
next	1.10;

1.10
date	2010.01.11.18.39.32;	author tgl;	state Exp;
branches;
next	1.9;

1.9
date	2009.08.27.16.59.38;	author tgl;	state Exp;
branches;
next	1.8;

1.8
date	2006.07.13.14.44.33;	author petere;	state Exp;
branches;
next	1.7;

1.7
date	2004.10.01.18.30.21;	author tgl;	state Exp;
branches;
next	1.6;

1.6
date	2003.11.29.19.51.36;	author pgsql;	state Exp;
branches;
next	1.5;

1.5
date	2003.07.26.20.42.55;	author momjian;	state Exp;
branches;
next	1.4;

1.4
date	2003.06.12.02.02.24;	author momjian;	state Exp;
branches;
next	1.3;

1.3
date	2001.07.30.14.52.42;	author momjian;	state Exp;
branches;
next	1.2;

1.2
date	2001.04.19.19.17.44;	author petere;	state Exp;
branches;
next	1.1;

1.1
date	2001.02.08.19.53.33;	author petere;	state Exp;
branches;
next	;


desc
@@


1.11
log
@Update startup scripts for Linux and FreeBSD.

Kevin Grittner
@
text
@#! /bin/sh

# chkconfig: 2345 98 02
# description: PostgreSQL RDBMS

# This is an example of a start/stop script for SysV-style init, such
# as is used on Linux systems.  You should edit some of the variables
# and maybe the 'echo' commands.
#
# Place this file at /etc/init.d/postgresql (or
# /etc/rc.d/init.d/postgresql) and make symlinks to
#   /etc/rc.d/rc0.d/K02postgresql
#   /etc/rc.d/rc1.d/K02postgresql
#   /etc/rc.d/rc2.d/K02postgresql
#   /etc/rc.d/rc3.d/S98postgresql
#   /etc/rc.d/rc4.d/S98postgresql
#   /etc/rc.d/rc5.d/S98postgresql
# Or, if you have chkconfig, simply:
# chkconfig --add postgresql
#
# Proper init scripts on Linux systems normally require setting lock
# and pid files under /var/run as well as reacting to network
# settings, so you should treat this with care.

# Original author:  Ryan Kirkpatrick <pgsql@@rkirkpat.net>

# $PostgreSQL: pgsql/contrib/start-scripts/linux,v 1.10 2010/01/11 18:39:32 tgl Exp $

## EDIT FROM HERE

# Installation prefix
prefix=/usr/local/pgsql

# Data directory
PGDATA="/usr/local/pgsql/data"

# Who to run the postmaster as, usually "postgres".  (NOT "root")
PGUSER=postgres

# Where to keep a log file
PGLOG="$PGDATA/serverlog"

# It's often a good idea to protect the postmaster from being killed by the
# OOM killer (which will tend to preferentially kill the postmaster because
# of the way it accounts for shared memory).  Setting the OOM_ADJ value to
# -17 will disable OOM kill altogether.  If you enable this, you probably want
# to compile PostgreSQL with "-DLINUX_OOM_ADJ=0", so that individual backends
# can still be killed by the OOM killer.
#OOM_ADJ=-17

## STOP EDITING HERE

# The path that is to be used for the script
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# What to use to start up the postmaster.  (If you want the script to wait
# until the server has started, you could use "pg_ctl start -w" here.
# But without -w, pg_ctl adds no value.)
DAEMON="$prefix/bin/postmaster"

# What to use to shut down the postmaster
PGCTL="$prefix/bin/pg_ctl"

set -e

# Only start if we can find the postmaster.
test -x $DAEMON ||
{
	echo "$DAEMON not found"
	if [ "$1" = "stop" ]
	then exit 0
	else exit 5
	fi
}


# Parse command line parameters.
case $1 in
  start)
	echo -n "Starting PostgreSQL: "
	test x"$OOM_ADJ" != x && echo "$OOM_ADJ" > /proc/self/oom_adj
	su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1
	echo "ok"
	;;
  stop)
	echo -n "Stopping PostgreSQL: "
	su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast"
	echo "ok"
	;;
  restart)
	echo -n "Restarting PostgreSQL: "
	su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast -w"
	test x"$OOM_ADJ" != x && echo "$OOM_ADJ" > /proc/self/oom_adj
	su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1
	echo "ok"
	;;
  reload)
        echo -n "Reload PostgreSQL: "
        su - $PGUSER -c "$PGCTL reload -D '$PGDATA' -s"
        echo "ok"
        ;;
  status)
	su - $PGUSER -c "$PGCTL status -D '$PGDATA'"
	;;
  *)
	# Print help
	echo "Usage: $0 {start|stop|restart|reload|status}" 1>&2
	exit 1
	;;
esac

exit 0
@


1.10
log
@Add some simple support and documentation for using process-specific oom_adj
settings to prevent the postmaster from being OOM-killed on Linux systems.

Alex Hunsaker and Tom Lane
@
text
@d27 1
a27 1
# $PostgreSQL: pgsql/contrib/start-scripts/linux,v 1.9 2009/08/27 16:59:38 tgl Exp $
d67 9
a75 1
test -x $DAEMON || exit 0
@


1.9
log
@Make it reasonably safe to use pg_ctl to start the postmaster from a boot-time
script.

To do this, have pg_ctl pass down its parent shell's PID in an environment
variable PG_GRANDPARENT_PID, and teach CreateLockFile() to disregard that PID
as a false match if it finds it in postmaster.pid.  This allows us to cope
with one level of postgres-owned shell process even with pg_ctl in the way,
so it's just as safe as starting the postmaster directly.  You still have to
be careful about how you write the initscript though.

Adjust the comments in contrib/start-scripts/ to not deprecate use of
pg_ctl.  Also, fix the ROTATELOGS option in the OSX script, which was
indulging in exactly the sort of unsafe coding that renders this fix
pointless :-(.  A pipe inside the "sudo" will probably result in more
than one postgres-owned process hanging around.
@
text
@d27 1
a27 1
# $PostgreSQL: pgsql/contrib/start-scripts/linux,v 1.8 2006/07/13 14:44:33 petere Exp $
d43 8
d73 1
d85 1
@


1.8
log
@Be consistent about not using ECHO_N/ECHO_C (seems unnecessary on Linux).
@
text
@d27 1
a27 1
# $PostgreSQL: pgsql/contrib/start-scripts/linux,v 1.7 2004/10/01 18:30:21 tgl Exp $
d48 3
a50 3
# What to use to start up the postmaster (we do NOT use pg_ctl for this,
# as it adds no value and can cause the postmaster to misrecognize a stale
# lock file)
@


1.7
log
@Adjust postmaster to recognize that a lockfile containing its parent's PID
must be stale.  Tweak example startup scripts to not use pg_ctl but launch
the postmaster directly, thereby ensuring that only the postmaster's direct
parent shell will be a postgres-owned process.  In combination these should
fix the longstanding problem of the postmaster sometimes refusing to start
during reboot because it thinks the old lockfile is not stale.
@
text
@d27 1
a27 1
# $PostgreSQL: pgsql-server/contrib/start-scripts/linux,v 1.6 2003/11/29 19:51:36 pgsql Exp $
a44 9
# Check for echo -n vs echo \c
if echo '\c' | grep -s c >/dev/null 2>&1 ; then
    ECHO_N="echo -n"
    ECHO_C=""
else
    ECHO_N="echo"
    ECHO_C='\c'
fi

d64 1
a64 1
	$ECHO_N "Starting PostgreSQL: "$ECHO_C
@


1.6
log
@
$Header: -> $PostgreSQL Changes ...
@
text
@d27 1
a27 1
# $PostgreSQL: /cvsroot/pgsql-server/contrib/start-scripts/linux,v 1.5 2003/07/26 20:42:55 momjian Exp $
d37 1
a37 1
# Who to run pg_ctl as, should be "postgres".
d57 7
a63 2
# What to use to start up the postmaster
DAEMON="$prefix/bin/pg_ctl"
d67 2
a68 2
# Only start if we can find pg_ctl.
test -f $DAEMON || exit 0
d74 1
a74 1
	su - $PGUSER -c "$DAEMON start -D '$PGDATA' -s -l $PGLOG" 
d79 1
a79 1
	su - $PGUSER -c "$DAEMON stop -D '$PGDATA' -s -m fast"
d84 2
a85 1
	su - $PGUSER -c "$DAEMON restart -D '$PGDATA' -s -m fast -l $PGLOG"
d90 1
a90 1
        su - $PGUSER -c "$DAEMON reload -D '$PGDATA' -s"
d94 1
a94 1
	su - $PGUSER -c "$DAEMON status -D '$PGDATA'"
@


1.5
log
@Fix for Linux startup script.

Slawomir Sudnik
@
text
@d27 1
a27 1
# $Header: /cvsroot/pgsql-server/contrib/start-scripts/linux,v 1.4 2003/06/12 02:02:24 momjian Exp $
@


1.4
log
@Add Linux restart --- Slawomir Sudnik
Add "-l $PGLOG" for restart --- Darko Prenosil
@
text
@d27 1
a27 1
# $Header: /cvsroot/pgsql-server/contrib/start-scripts/linux,v 1.3 2001/07/30 14:52:42 momjian Exp $
d86 1
@


1.3
log
@Patch to add comments to Linux startup script.

Rene Pijlman
@
text
@d27 1
a27 1
# $Header: /home/projects/pgsql/cvsroot/pgsql/contrib/start-scripts/linux,v 1.2 2001/04/19 19:17:44 petere Exp $
d79 1
a79 1
	su - $PGUSER -c "$DAEMON restart -D '$PGDATA' -s -m fast"
d82 4
d91 1
a91 1
	echo "Usage: $0 {start|stop|restart|status}" 1>&2
@


1.2
log
@Pass -D option to pg_ctl because export PGDATA won't be preserved across
'su -l'.

Reported by <VASQUEZ_JASON@@LILLY.COM>.
@
text
@d3 3
d18 2
a19 1
# Or check out the chkconfig program, if you have it.
d27 1
a27 1
# $Header: /home/projects/pgsql/cvsroot/pgsql/contrib/start-scripts/linux,v 1.1 2001/02/08 19:53:33 petere Exp $
@


1.1
log
@Remove outdated contrib/linux start scripts.  Beat some sense into
contrib/init.d start script.  Place into more aptly named directory.  Maybe
we could add scripts for other platforms here later.
@
text
@d23 1
a23 1
# $Header$
a40 2
export PGDATA

d65 1
a65 1
	su - $PGUSER -c "$DAEMON start -s -l $PGLOG" 
d70 1
a70 1
	su - $PGUSER -c "$DAEMON stop -s -m fast"
d75 1
a75 1
	su - $PGUSER -c "$DAEMON restart -s -m fast"
d79 1
a79 1
	su - $PGUSER -c "$DAEMON status"
@
