tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jsdelf...@apache.org
Subject svn commit: r1225904 - in /tuscany/sca-cpp/trunk/components: cache/ sqldb/
Date Fri, 30 Dec 2011 19:52:30 GMT
Author: jsdelfino
Date: Fri Dec 30 19:52:29 2011
New Revision: 1225904

URL: http://svn.apache.org/viewvc?rev=1225904&view=rev
Log:
Add external configuration of Memcached and PostgreSQL logging, to allow the logs to be piped
to Scribe or the HTTPD log rotation program.

Added:
    tuscany/sca-cpp/trunk/components/cache/memcached-log-conf
      - copied, changed from r1222604, tuscany/sca-cpp/trunk/components/sqldb/pgsql-stop
    tuscany/sca-cpp/trunk/components/sqldb/pgsql-log-conf
      - copied, changed from r1222604, tuscany/sca-cpp/trunk/components/sqldb/pgsql-start
Modified:
    tuscany/sca-cpp/trunk/components/cache/Makefile.am
    tuscany/sca-cpp/trunk/components/cache/memcached-start
    tuscany/sca-cpp/trunk/components/sqldb/Makefile.am
    tuscany/sca-cpp/trunk/components/sqldb/pgsql
    tuscany/sca-cpp/trunk/components/sqldb/pgsql-backup
    tuscany/sca-cpp/trunk/components/sqldb/pgsql-conf
    tuscany/sca-cpp/trunk/components/sqldb/pgsql-standby-conf
    tuscany/sca-cpp/trunk/components/sqldb/pgsql-start
    tuscany/sca-cpp/trunk/components/sqldb/pgsql-stop

Modified: tuscany/sca-cpp/trunk/components/cache/Makefile.am
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/cache/Makefile.am?rev=1225904&r1=1225903&r2=1225904&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/cache/Makefile.am (original)
+++ tuscany/sca-cpp/trunk/components/cache/Makefile.am Fri Dec 30 19:52:29 2011
@@ -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

Copied: tuscany/sca-cpp/trunk/components/cache/memcached-log-conf (from r1222604, tuscany/sca-cpp/trunk/components/sqldb/pgsql-stop)
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/cache/memcached-log-conf?p2=tuscany/sca-cpp/trunk/components/cache/memcached-log-conf&p1=tuscany/sca-cpp/trunk/components/sqldb/pgsql-stop&r1=1222604&r2=1225904&rev=1225904&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/sqldb/pgsql-stop (original)
+++ tuscany/sca-cpp/trunk/components/cache/memcached-log-conf Fri Dec 30 19:52:29 2011
@@ -17,11 +17,21 @@
 #  specific language governing permissions and limitations
 #  under the License.
 
-# Stop postgresql
+# 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`
 
-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
+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
 

Modified: tuscany/sca-cpp/trunk/components/cache/memcached-start
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/cache/memcached-start?rev=1225904&r1=1225903&r2=1225904&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/cache/memcached-start (original)
+++ tuscany/sca-cpp/trunk/components/cache/memcached-start Fri Dec 30 19:52:29 2011
@@ -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
 

Modified: tuscany/sca-cpp/trunk/components/sqldb/Makefile.am
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/sqldb/Makefile.am?rev=1225904&r1=1225903&r2=1225904&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/sqldb/Makefile.am (original)
+++ tuscany/sca-cpp/trunk/components/sqldb/Makefile.am Fri Dec 30 19:52:29 2011
@@ -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

Modified: tuscany/sca-cpp/trunk/components/sqldb/pgsql
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/sqldb/pgsql?rev=1225904&r1=1225903&r2=1225904&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/sqldb/pgsql (original)
+++ tuscany/sca-cpp/trunk/components/sqldb/pgsql Fri Dec 30 19:52:29 2011
@@ -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
 

Modified: tuscany/sca-cpp/trunk/components/sqldb/pgsql-backup
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/sqldb/pgsql-backup?rev=1225904&r1=1225903&r2=1225904&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/sqldb/pgsql-backup (original)
+++ tuscany/sca-cpp/trunk/components/sqldb/pgsql-backup Fri Dec 30 19:52:29 2011
@@ -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
 

Modified: tuscany/sca-cpp/trunk/components/sqldb/pgsql-conf
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/sqldb/pgsql-conf?rev=1225904&r1=1225903&r2=1225904&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/sqldb/pgsql-conf (original)
+++ tuscany/sca-cpp/trunk/components/sqldb/pgsql-conf Fri Dec 30 19:52:29 2011
@@ -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 <
 
 # 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             
 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

Copied: tuscany/sca-cpp/trunk/components/sqldb/pgsql-log-conf (from r1222604, tuscany/sca-cpp/trunk/components/sqldb/pgsql-start)
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/sqldb/pgsql-log-conf?p2=tuscany/sca-cpp/trunk/components/sqldb/pgsql-log-conf&p1=tuscany/sca-cpp/trunk/components/sqldb/pgsql-start&r1=1222604&r2=1225904&rev=1225904&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/sqldb/pgsql-start (original)
+++ tuscany/sca-cpp/trunk/components/sqldb/pgsql-log-conf Fri Dec 30 19:52:29 2011
@@ -17,13 +17,21 @@
 #  specific language governing permissions and limitations
 #  under the License.
 
-# Start postgresql
+# 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`
 
-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 [ "$2" = "" ]; then
+    cat >$root/sqldb/log.conf << EOF
+cat >>$root/logs/postgresql
+EOF
+
+else
+    cat >$root/sqldb/log.conf << EOF
+$2
+EOF
+
+fi
 

Modified: tuscany/sca-cpp/trunk/components/sqldb/pgsql-standby-conf
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/sqldb/pgsql-standby-conf?rev=1225904&r1=1225903&r2=1225904&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/sqldb/pgsql-standby-conf (original)
+++ tuscany/sca-cpp/trunk/components/sqldb/pgsql-standby-conf Fri Dec 30 19:52:29 2011
@@ -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

Modified: tuscany/sca-cpp/trunk/components/sqldb/pgsql-start
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/sqldb/pgsql-start?rev=1225904&r1=1225903&r2=1225904&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/sqldb/pgsql-start (original)
+++ tuscany/sca-cpp/trunk/components/sqldb/pgsql-start Fri Dec 30 19:52:29 2011
@@ -22,8 +22,22 @@ here=`echo "import os; print os.path.rea
 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
 

Modified: tuscany/sca-cpp/trunk/components/sqldb/pgsql-stop
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/sqldb/pgsql-stop?rev=1225904&r1=1225903&r2=1225904&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/sqldb/pgsql-stop (original)
+++ tuscany/sca-cpp/trunk/components/sqldb/pgsql-stop Fri Dec 30 19:52:29 2011
@@ -22,6 +22,13 @@ here=`echo "import os; print os.path.rea
 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
 



Mime
View raw message