summaryrefslogtreecommitdiff
blob: ec157a2f131b8bda3de9f5ce35c1811490e32b10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/sbin/runscript
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-db/postgresql/files/pg_autovacuum.init-7.4,v 1.3 2006/11/11 13:39:14 dev-zero Exp $

depend() {
	need postgresql logger
}

start() {
	ebegin "Starting pg_autovacuum"

	echo
	echo -n "Waiting max. 20 sec. for PostgreSQL to start "
	CONTINUE=0
	TOO_LONG=0
	while [ "$CONTINUE" -eq 0 ] && [ $TOO_LONG -lt 20 ]
	do
		psql -U $PGUSER -d template1 -c "SELECT 1" 1> /dev/null 2> /dev/null
		if [ "$?" -eq 0 ]
		then
			CONTINUE=1
		else
			echo -n "."
			TOO_LONG=`expr $TOO_LONG + 1`
			sleep 1
		fi
	done

	start-stop-daemon -o --chuid $PGUSER --start --quiet --exec /usr/bin/pg_autovacuum -- -D ${PGPORT:+-p ${PGPORT}} -v $VACUUM_BASE -V $VACUUM_SCALE -s $SLEEP_BASE -S $SLEEP_SCALE -L $PG_AUTOVACUUM_LOG

	sleep 1
	pidof /usr/bin/pg_autovacuum > /dev/null
	if [ $? -eq 0 ] ; then
		eend 0
	else
		eerror
		eerror "Please check the $PG_AUTOVACUUM_LOG log file for errors."
		eerror "You may need to add the following lines to /var/lib/postgresql/data/postgresql.conf and restart PostgreSQL."
		eerror " stats_start_collector = true"
		eerror " stats_row_level = true"
		eerror
		eerror "Please read ___DOCDIR___/contrib/README.pg_autovacuum for details!"
		eerror
		eend 1
	fi
}

stop() {
	ebegin "Stopping pg_autovacuum"
	start-stop-daemon --stop --quiet --exec /usr/bin/pg_autovacuum
	eend $?
}