- Fix pid file path in init script.

- Fix spec file -- we don't use short_name macro in pgcore spec file.
- Create pgpool pid file directory.
- Fix stop/start routines, also improve init script a bit.
- Install conf files to a new directory (/etc/pgpool-II), and get rid of
    sample conf files.
This commit is contained in:
Devrim GÜNDÜZ 2009-03-23 01:01:26 +00:00
commit 91aad2fbe4
3 changed files with 106 additions and 53 deletions

View file

@ -1,24 +1,22 @@
--- pgpool.conf.sample.old 2008-08-12 08:26:07.000000000 +0300
+++ pgpool.conf.sample 2008-08-12 08:27:31.000000000 +0300
--- pgpool.conf.sample.old 2009-03-22 22:18:52.000000000 +0200
+++ pgpool.conf.sample 2009-03-22 22:46:20.000000000 +0200
@@ -12,16 +12,14 @@
# Port number for pgpool communication manager
pcp_port = 9898
-# Unix domain socket path. (The Debian package defaults to
-# /var/run/postgresql.)
-socket_dir = '/tmp'
+# Unix domain socket path.
+socket_dir = '/var/run'
+# Unix domain socket path.
socket_dir = '/tmp'
# Unix domain socket path for pgpool communication manager.
-# (Debian package defaults to /var/run/postgresql)
-pcp_socket_dir = '/tmp'
+pcp_socket_dir = '/var/run'
pcp_socket_dir = '/tmp'
-# Unix domain socket path for the backend. Debian package defaults to /var/run/postgresql!
-backend_socket_dir = '/tmp'
+# Unix domain socket path for the backend.
+backend_socket_dir = '/var/run'
+# Unix domain socket path for the backend.
+backend_socket_dir = '/var/run/pgpool'
# pgpool communication manager timeout. 0 means no timeout, but strongly not recommended!
pcp_timeout = 10
@ -27,7 +25,22 @@
# Logging directory
-logdir = '/tmp'
+logdir = '/var/run'
+logdir = '/var/log/pgpool'
# Replication mode
replication_mode = false
# pid file name
pid_file_name = '/var/run/pgpool/pgpool.pid'
@@ -166,10 +164,10 @@
# backend_hostname, backend_port, backend_weight
# here are examples
-#backend_hostname0 = 'host1'
-#backend_port0 = 5432
-#backend_weight0 = 1
-#backend_data_directory0 = '/data'
+backend_hostname0 = 'localhost'
+backend_port0 = 5432
+backend_weight0 = 1
+backend_data_directory0 = '/var/lib/pgsql/data'
#backend_hostname1 = 'host2'
#backend_port1 = 5433
#backend_weight1 = 1

View file

@ -8,12 +8,14 @@
#
# v1.0.0 Devrim GUNDUZ <devrim@CommandPrompt.com>
# - Initial version of Red Hat / Fedora init script
# v1.0.1 Devrim GUNDUZ <devrim@CommandPrompt.com>
# - - Honor /etc/sysconfig/pgpool settings. Previously we could never
# customize PGPOOLPID=/var/run/pgpool.pid et al.
# - Remaining hardcoded paths replaced by customizable variables
# such as $PGPOOLCONF .
#
# v2.2 Devrim GUNDUZ <devrim@CommandPrompt.com>
# - New and improved version which has some fixes.
if [ -r /etc/sysconfig/pgpool ]; then
. /etc/sysconfig/pgpool
fi
# Source function library.
INITD=/etc/rc.d/init.d
. $INITD/functions
@ -29,30 +31,23 @@ TYPESET=`typeset -f|grep "declare"`
[ "${NETWORKING}" = "no" ] && exit 0
# Find the name of the script
NAME=pgpool
NAME=`basename $0`
if [ ${NAME:0:1} = "S" -o ${NAME:0:1} = "K" ]
then
NAME=${NAME:3}
fi
# Set defaults for configuration variables
PGPOOLENGINE=/usr/bin
PGPOOLDAEMON=$PGPOOLENGINE/pgpool
PGPOOLCONF=/etc/pgpool.conf
PGPOOLPID=/var/run/pgpool.pid
PGPOOLCONF=/etc/pgpool-II/pgpool.conf
PGPOOLPIDDIR=/var/run/pgpool
PGPOOLLOG=/var/log/pgpool.log
# read in the site custom setup
if [ -r /etc/sysconfig/pgpool ]; then
. /etc/sysconfig/pgpool
fi
test -x $PGPOOLDAEMON || exit 5
# Create the pgpool.log log file if it does not exist
if [ ! -r $PGPOOLLOG ]
then
touch $PGPOOLLOG
fi
# Check whether the pgpool.conf config file exists or not
if [ ! -r "$PGPOOLCONF" ]
# Check whether the config file exists or not
if [ ! -r $PGPOOLCONF ]
then
echo "$PGPOOLCONF not found"
RETVAL=1
@ -60,12 +55,36 @@ then
exit
fi
# Create the log file if it does not exist
if [ ! -x $PGPOOLLOG ]
then
touch $PGPOOLLOG
chown postgres: $PGPOOLLOG
fi
if [ ! -d $PGPOOLPIDDIR ]
then
mkdir $PGPOOLPIDDIR
chown postgres: $PGPOOLPIDDIR
fi
script_result=0
start(){
pid=`pidof -s "$PGPOOLDAEMON"`
if [ $pid ]
then
echo "pgpool is already running with pid $pid"
failure "$PGPOQL_START"
echo
script_result=1
exit 1
fi
PGPOOL_START=$"Starting ${NAME} service: "
echo -n "$PGPOOL_START"
$PGPOOLDAEMON -f $PGPOOLCONF $OPTS & >> "$PGPOOLLOG" 2>&1 < /dev/null
sleep 2
@ -76,7 +95,7 @@ start(){
touch /var/lock/subsys/${NAME}
echo
else
failure "$PSQL_START"
failure "$PGPOQL_START"
echo
script_result=1
fi
@ -88,7 +107,8 @@ stop(){
RETVAL=1
failure
else
killproc $PGPOOLDAEMON
killproc /usr/bin/pgpool
# $PGPOOLDAEMON stop & >> "$PGPOOLLOG" 2>&1 < /dev/null
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/${NAME}
fi;
@ -98,7 +118,7 @@ stop(){
switch() {
echo -n $"Sending switchover request to $NAME "
$PGPOOLDAEMON switch >> "$PGPOOLLOG" 2>&1 < /dev/null
$PGPOOLDAEMON -f $PGPOOLCONF switch >> "$PGPOOLLOG" 2>&1 < /dev/null
RETVAL=$?
echo
if [ $RETVAL -eq 0 ]
@ -116,22 +136,23 @@ restart(){
}
reload(){
echo -n $"Reloading ${NAME}: "
if [ -n "`pidfileofproc $PGPOOLDAEMON`" ] ; then
killproc $PGPOOLDAEMON -HUP
else
failure $"Reloading ${NAME}"
fi
RETVAL=$?
echo
echo -n $"Reloading ${NAME}: "
if [ -n "`pidfileofproc $PGPOOLDAEMON`" ] ; then
killproc $PGPOOLDAEMON -HUP
else
failure $"Reloading ${NAME}"
fi
RETVAL=$?
echo
}
condrestart(){
[ -e /var/lock/subsys/${NAME} ] && restart
[ -e /var/lock/subsys/${NAME} ] && restart
}
condstop(){
[ -e /var/lock/subsys/${NAME} ] && stop
[ -e /var/lock/subsys/${NAME} ] && stop
}
# See how we were called.

View file

@ -3,7 +3,7 @@
Summary: Pgpool is a connection pooling/replication server for PostgreSQL
Name: postgresql-%{short_name}
Version: 2.2
Release: 1%{?dist}
Release: 1%{?dist}.1
License: BSD
Group: Applications/Databases
URL: http://pgpool.projects.PostgreSQL.org
@ -47,7 +47,7 @@ Development headers and libraries for pgpool-II.
%patch1 -p0
%build
%configure --with-pgsql-includedir=%{_includedir}/pgsql --with-pgsql-lib=%{_libdir}/pgsql --disable-static --with-pam --disable-rpath
%configure --with-pgsql-includedir=%{_includedir}/pgsql --with-pgsql-lib=%{_libdir}/pgsql --disable-static --with-pam --disable-rpath --sysconfdir=%{_sysconfdir}/%{short_name}/
make %{?_smp_flags}
@ -55,7 +55,10 @@ make %{?_smp_flags}
rm -rf %{buildroot}
make %{?_smp_flags} DESTDIR=%{buildroot} install
install -d %{buildroot}%{_datadir}/%{short_name}
mv %{buildroot}/%{_sysconfdir}/*.conf.sample %{buildroot}%{_datadir}/%{short_name}
install -d %{buildroot}%{_sysconfdir}/%{short_name}
mv %{buildroot}/%{_sysconfdir}/%{short_name}/pcp.conf.sample %{buildroot}%{_sysconfdir}/%{short_name}/pcp.conf
mv %{buildroot}/%{_sysconfdir}/%{short_name}/pgpool.conf.sample %{buildroot}%{_sysconfdir}/%{short_name}/pgpool.conf
mv %{buildroot}/%{_sysconfdir}/%{short_name}/pool_hba.conf.sample %{buildroot}%{_sysconfdir}/%{short_name}/pool_hba.conf
install -d %{buildroot}%{_initrddir}
install -m 755 %{SOURCE1} %{buildroot}%{_initrddir}/pgpool
install -d %{buildroot}%{_sysconfdir}/sysconfig
@ -88,11 +91,12 @@ chkconfig --add pgpool
%{_bindir}/pcp_systemdb_info
%{_bindir}/pg_md5
%{_mandir}/man8/pgpool*
%dir %{_datadir}/%{short_name}
%{_datadir}/%{short_name}/system_db.sql
%{_libdir}/libpcp.so.*
%attr(764,root,root) %{_datadir}/%{short_name}/*.conf.sample
%{_datadir}/%{short_name}/pgpool.pam
%{_initrddir}/pgpool
%attr(764,root,apache) %config(noreplace) %{_sysconfdir}/%{short_name}/*.conf
%config(noreplace) %{_sysconfdir}/sysconfig/pgpool
%files devel
@ -102,14 +106,29 @@ chkconfig --add pgpool
%{_libdir}/libpcp.so
%changelog
* Mon Mar 23 2009 Devrim Gunduz <devrim@CommandPrompt.com> 2.2-1.1
- Fix pid file path in init script.
- Fix spec file -- we don't use short_name macro in pgcore spec file.
- Create pgpool pid file directory.
- Fix stop/start routines, also improve init script a bit.
- Install conf files to a new directory (/etc/pgpool-II), and get rid
of sample conf files.
* Sun Mar 1 2009 Devrim Gunduz <devrim@CommandPrompt.com> 2.2-1
- Update to 2.2
- Fix URL
- Update URL
* Thu Feb 26 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild
* Thu Dec 4 2008 Michael Schwendt <mschwendt@fedoraproject.org> 2.1-2
- Include /usr/share/pgpool-II directory.
* Tue Aug 12 2008 Devrim Gunduz <devrim@CommandPrompt.com> 2.1-1
- Update to 2.1 Gold
- Set group of sample config files to root, not apache. Fixes RH #442372.
- Update patch #1
- Update patch #1: Fix build failure caused by new default patch
fuzz = 0 policy in rawhide
* Fri Apr 11 2008 Devrim Gunduz <devrim@CommandPrompt.com> 2.1-0.2.beta2
- Fix Requires: issue, per #442021 (Alex Lancaster)