summaryrefslogtreecommitdiffstats
path: root/sca-cpp
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2011-12-30 19:52:29 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2011-12-30 19:52:29 +0000
commit85d3307d7670dc1b8b0d3ffab814e518e7f0a771 (patch)
tree50b2fc37daf64ffd0fe3dcb801e3f97f7d9f1ba7 /sca-cpp
parent681567b28116421496c4b7560a5b70f9730b8a79 (diff)
Add external configuration of Memcached and PostgreSQL logging, to allow the logs to be piped to Scribe or the HTTPD log rotation program.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1225904 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--sca-cpp/trunk/components/cache/Makefile.am2
-rwxr-xr-xsca-cpp/trunk/components/cache/memcached-log-conf37
-rwxr-xr-xsca-cpp/trunk/components/cache/memcached-start17
-rw-r--r--sca-cpp/trunk/components/sqldb/Makefile.am2
-rwxr-xr-xsca-cpp/trunk/components/sqldb/pgsql6
-rwxr-xr-xsca-cpp/trunk/components/sqldb/pgsql-backup12
-rwxr-xr-xsca-cpp/trunk/components/sqldb/pgsql-conf38
-rwxr-xr-xsca-cpp/trunk/components/sqldb/pgsql-log-conf37
-rwxr-xr-xsca-cpp/trunk/components/sqldb/pgsql-standby-conf11
-rwxr-xr-xsca-cpp/trunk/components/sqldb/pgsql-start22
-rwxr-xr-xsca-cpp/trunk/components/sqldb/pgsql-stop11
11 files changed, 174 insertions, 21 deletions
diff --git a/sca-cpp/trunk/components/cache/Makefile.am b/sca-cpp/trunk/components/cache/Makefile.am
index 159a941947..d14bd3a542 100644
--- a/sca-cpp/trunk/components/cache/Makefile.am
+++ b/sca-cpp/trunk/components/cache/Makefile.am
@@ -18,7 +18,7 @@
incl_HEADERS = *.hpp
incldir = $(prefix)/include/components/cache
-dist_comp_SCRIPTS = memcached-start memcached-stop
+dist_comp_SCRIPTS = memcached-log-conf memcached-start memcached-stop
compdir=$(prefix)/components/cache
comp_DATA = memcached.prefix
diff --git a/sca-cpp/trunk/components/cache/memcached-log-conf b/sca-cpp/trunk/components/cache/memcached-log-conf
new file mode 100755
index 0000000000..d8a4896eff
--- /dev/null
+++ b/sca-cpp/trunk/components/cache/memcached-log-conf
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Configure memcached logging
+here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here`
+mkdir -p $1
+root=`echo "import os; print os.path.realpath('$1')" | python`
+
+mkdir -p $root/memcached
+if [ "$2" = "" ]; then
+ cat >$root/memcached/log.conf << EOF
+cat >>$root/logs/memcached
+EOF
+
+else
+ cat >$root/memcached/log.conf << EOF
+$2
+EOF
+
+fi
+
diff --git a/sca-cpp/trunk/components/cache/memcached-start b/sca-cpp/trunk/components/cache/memcached-start
index 0946da28f5..a49ad2919a 100755
--- a/sca-cpp/trunk/components/cache/memcached-start
+++ b/sca-cpp/trunk/components/cache/memcached-start
@@ -19,8 +19,9 @@
# Start memcached
here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here`
+root=`echo "import os; print os.path.realpath('$1')" | python`
-addr=$1
+addr=$2
if [ "$addr" = "" ]; then
ip=""
port="11211"
@@ -30,9 +31,19 @@ else
fi
memcached_prefix=`cat $here/memcached.prefix`
+
+if [ -f "$root/memcached/log.conf" ]; then
+ log=`cat $root/memcached/log.conf`
+ v="-vv"
+else
+ mkdir -p $root/logs
+ log="cat >>$root/logs/memcached"
+ v=""
+fi
+
if [ "$ip" = "" ]; then
- $memcached_prefix/bin/memcached -d -m 4 -p $port
+ ($memcached_prefix/bin/memcached -d -m 4 -p $port $v 2>&1 | $log)&
else
- $memcached_prefix/bin/memcached -d -l $ip -m 4 -p $port
+ ($memcached_prefix/bin/memcached -d -l $ip -m 4 -p $port $v 2>&1 | $log)&
fi
diff --git a/sca-cpp/trunk/components/sqldb/Makefile.am b/sca-cpp/trunk/components/sqldb/Makefile.am
index faa10ec00b..0443de07d9 100644
--- a/sca-cpp/trunk/components/sqldb/Makefile.am
+++ b/sca-cpp/trunk/components/sqldb/Makefile.am
@@ -22,7 +22,7 @@ INCLUDES = -I${PGSQL_INCLUDE}
incl_HEADERS = *.hpp
incldir = $(prefix)/include/components/sqldb
-dist_comp_SCRIPTS = pgsql-conf pgsql-start pgsql-stop pgsql pgsql-standby-conf pgsql-backup
+dist_comp_SCRIPTS = pgsql-conf pgsql-log-conf pgsql-start pgsql-stop pgsql pgsql-standby-conf pgsql-backup
compdir=$(prefix)/components/sqldb
comp_DATA = pgsql.prefix
diff --git a/sca-cpp/trunk/components/sqldb/pgsql b/sca-cpp/trunk/components/sqldb/pgsql
index 23b78b90ec..8079fde7b1 100755
--- a/sca-cpp/trunk/components/sqldb/pgsql
+++ b/sca-cpp/trunk/components/sqldb/pgsql
@@ -31,5 +31,9 @@ else
cmd="$3"
fi
-$pgsql_prefix/bin/psql -h $host -p $port -c "$cmd" db
+if [ "$cmd" = "" ]; then
+ $pgsql_prefix/bin/psql -h $host -p $port db
+else
+ $pgsql_prefix/bin/psql -h $host -p $port -c "$cmd" db
+fi
diff --git a/sca-cpp/trunk/components/sqldb/pgsql-backup b/sca-cpp/trunk/components/sqldb/pgsql-backup
index 0c2a1289a3..3c0be60e77 100755
--- a/sca-cpp/trunk/components/sqldb/pgsql-backup
+++ b/sca-cpp/trunk/components/sqldb/pgsql-backup
@@ -30,12 +30,20 @@ else
fi
pgsql_prefix=`cat $here/pgsql.prefix`
-$pgsql_prefix/bin/psql -h $host -p $port -c "SELECT pg_start_backup('backup', true)" db 1>>$root/logs/postgresql 2>&1
+
+if [ -f "$root/sqldb/log.conf" ]; then
+ pgsql_log=`cat $root/sqldb/log.conf`
+else
+ mkdir -p $root/logs
+ pgsql_log="cat >>$root/logs/postgresql"
+fi
+
+$pgsql_prefix/bin/psql -h $host -p $port -c "SELECT pg_start_backup('backup', true)" db 2>&1 | $pgsql_log
echo "Content-type: application/x-compressed"
echo
tar -C $root/sqldb -cz data
-$pgsql_prefix/bin/psql -h $host -p $port -c "SELECT pg_stop_backup()" db 1>>$root/logs/postgresql 2>&1
+$pgsql_prefix/bin/psql -h $host -p $port -c "SELECT pg_stop_backup()" db 2>&1 | $pgsql_log
diff --git a/sca-cpp/trunk/components/sqldb/pgsql-conf b/sca-cpp/trunk/components/sqldb/pgsql-conf
index f0ea218b25..e3eb1c8dc3 100755
--- a/sca-cpp/trunk/components/sqldb/pgsql-conf
+++ b/sca-cpp/trunk/components/sqldb/pgsql-conf
@@ -38,9 +38,16 @@ pgsql_prefix=`cat $here/pgsql.prefix`
mkdir -p $root/sqldb/data
chmod 700 $root/sqldb/data
mkdir -p $root/sqldb/archive
-mkdir -p $root/logs
+
+if [ -f "$root/sqldb/log.conf" ]; then
+ pgsql_log=`cat $root/sqldb/log.conf`
+else
+ mkdir -p $root/logs
+ pgsql_log="cat >>$root/logs/postgresql"
+fi
+
if [ ! -f $root/sqldb/data/postgresql.conf ]; then
- $pgsql_prefix/bin/pg_ctl init -D $root/sqldb/data 1>>$root/logs/postgresql 2>&1
+ $pgsql_prefix/bin/pg_ctl init -D $root/sqldb/data 2>&1 | $pgsql_log
cp $root/sqldb/data/postgresql.conf $root/sqldb/data/postgresql-init.conf
cp $root/sqldb/data/pg_hba.conf $root/sqldb/data/pg_hba-init.conf
fi
@@ -51,6 +58,17 @@ cat >>$root/sqldb/data/postgresql.conf <<EOF
# Generated by: pgsql-conf $*
+# Setup logging
+log_min_messages = INFO
+log_min_error_statement = INFO
+log_min_duration_statement = 0
+log_checkpoints = on
+log_connections = on
+log_disconnections = on
+log_duration = on
+log_lock_waits = on
+log_statement = all
+
# Listen
listen_addresses = '$ip'
port = $port
@@ -78,9 +96,19 @@ host replication all samenet trust
EOF
# Create the db
-$pgsql_prefix/bin/pg_ctl start -w -D $root/sqldb/data -l $root/logs/postgresql 1>>$root/logs/postgresql 2>&1
-$pgsql_prefix/bin/createdb -h localhost -p $port db 1>>$root/logs/postgresql 2>&1
-$pgsql_prefix/bin/pg_ctl stop -w -D $root/sqldb/data 1>>$root/logs/postgresql 2>&1
+($pgsql_prefix/bin/pg_ctl start -W -D $root/sqldb/data 2>&1 | $pgsql_log)&
+sti=0
+while [ $sti -ne 30 ]; do
+ st=`$pgsql_prefix/bin/pg_ctl status -D $root/sqldb/data | grep 'server is running'`
+ if [ "$st" != "" ]; then
+ break
+ fi
+ sleep 1
+ sti=$((sti+1))
+done
+
+$pgsql_prefix/bin/createdb -h localhost -p $port db 2>&1 | $pgsql_log
+$pgsql_prefix/bin/pg_ctl stop -w -D $root/sqldb/data 2>&1 | $pgsql_log
# Generate database backup script
mkdir -p $root/sqldb/scripts
diff --git a/sca-cpp/trunk/components/sqldb/pgsql-log-conf b/sca-cpp/trunk/components/sqldb/pgsql-log-conf
new file mode 100755
index 0000000000..c68b4b718d
--- /dev/null
+++ b/sca-cpp/trunk/components/sqldb/pgsql-log-conf
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Configure postgresql logging
+here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here`
+mkdir -p $1
+root=`echo "import os; print os.path.realpath('$1')" | python`
+
+mkdir -p $root/sqldb
+if [ "$2" = "" ]; then
+ cat >$root/sqldb/log.conf << EOF
+cat >>$root/logs/postgresql
+EOF
+
+else
+ cat >$root/sqldb/log.conf << EOF
+$2
+EOF
+
+fi
+
diff --git a/sca-cpp/trunk/components/sqldb/pgsql-standby-conf b/sca-cpp/trunk/components/sqldb/pgsql-standby-conf
index 5fcb7128f2..291d950e94 100755
--- a/sca-cpp/trunk/components/sqldb/pgsql-standby-conf
+++ b/sca-cpp/trunk/components/sqldb/pgsql-standby-conf
@@ -47,14 +47,21 @@ else
fi
pgsql_prefix=`cat $here/pgsql.prefix`
+
+if [ -f "$root/sqldb/log.conf" ]; then
+ pgsql_log=`cat $root/sqldb/log.conf`
+else
+ mkdir -p $root/logs
+ pgsql_log="cat >>$root/logs/postgresql"
+fi
+
mkdir -p $root/sqldb/data
chmod 700 $root/sqldb/data
mkdir -p $root/sqldb/archive
-mkdir -p $root/logs
# Initialize from a backup of the master
if [ ! -f $root/sqldb/data/postgresql.conf ]; then
- (wget http://$mhost:$mhttpport/pgsql-backup -O - | tar -C $root/sqldb -xz) 1>>$root/logs/postgresql 2>&1
+ (wget http://$mhost:$mhttpport/pgsql-backup -O - | tar -C $root/sqldb -xz) 2>&1 | $pgsql_log
rm -rf $root/sqldb/data/postmaster.pid $root/sqldb/data/pg_xlog
mkdir -p $root/sqldb/data/pg_xlog/archive_status
chmod 700 $root/sqldb/data/pg_xlog/archive_status
diff --git a/sca-cpp/trunk/components/sqldb/pgsql-start b/sca-cpp/trunk/components/sqldb/pgsql-start
index ac35e80bf1..9960c5d258 100755
--- a/sca-cpp/trunk/components/sqldb/pgsql-start
+++ b/sca-cpp/trunk/components/sqldb/pgsql-start
@@ -22,8 +22,22 @@ here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $h
root=`echo "import os; print os.path.realpath('$1')" | python`
pgsql_prefix=`cat $here/pgsql.prefix`
-mkdir -p $root/sqldb
-mkdir -p $root/logs
-$pgsql_prefix/bin/pg_ctl start -w -D $root/sqldb/data -l $root/logs/postgresql 1>>$root/logs/postgresql 2>&1
-sleep 1
+
+if [ -f "$root/sqldb/log.conf" ]; then
+ pgsql_log=`cat $root/sqldb/log.conf`
+else
+ mkdir -p $root/logs
+ pgsql_log="cat >>$root/logs/postgresql"
+fi
+
+($pgsql_prefix/bin/pg_ctl start -W -D $root/sqldb/data 2>&1 | $pgsql_log)&
+sti=0
+while [ $sti -ne 30 ]; do
+ st=`$pgsql_prefix/bin/pg_ctl status -D $root/sqldb/data | grep 'server is running'`
+ if [ "$st" != "" ]; then
+ break
+ fi
+ sleep 1
+ sti=$((sti+1))
+done
diff --git a/sca-cpp/trunk/components/sqldb/pgsql-stop b/sca-cpp/trunk/components/sqldb/pgsql-stop
index e226b35d0d..9c5c9aae57 100755
--- a/sca-cpp/trunk/components/sqldb/pgsql-stop
+++ b/sca-cpp/trunk/components/sqldb/pgsql-stop
@@ -22,6 +22,13 @@ here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $h
root=`echo "import os; print os.path.realpath('$1')" | python`
pgsql_prefix=`cat $here/pgsql.prefix`
-mkdir -p $root/logs
-$pgsql_prefix/bin/pg_ctl stop -w -D $root/sqldb/data 1>>$root/logs/postgresql 2>&1
+
+if [ -f "$root/sqldb/log.conf" ]; then
+ pgsql_log=`cat $root/sqldb/log.conf`
+else
+ mkdir -p $root/logs
+ pgsql_log="cat >>$root/logs/postgresql"
+fi
+
+$pgsql_prefix/bin/pg_ctl stop -w -D $root/sqldb/data 2>&1 | $pgsql_log