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
This commit is contained in:
parent
681567b281
commit
85d3307d76
11 changed files with 175 additions and 22 deletions
sca-cpp/trunk/components
2
sca-cpp/trunk/components/cache/Makefile.am
vendored
2
sca-cpp/trunk/components/cache/Makefile.am
vendored
|
@ -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
|
||||
|
|
37
sca-cpp/trunk/components/cache/memcached-log-conf
vendored
Executable file
37
sca-cpp/trunk/components/cache/memcached-log-conf
vendored
Executable file
|
@ -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
|
||||
|
19
sca-cpp/trunk/components/cache/memcached-start
vendored
19
sca-cpp/trunk/components/cache/memcached-start
vendored
|
@ -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 [ "$ip" = "" ]; then
|
||||
$memcached_prefix/bin/memcached -d -m 4 -p $port
|
||||
|
||||
if [ -f "$root/memcached/log.conf" ]; then
|
||||
log=`cat $root/memcached/log.conf`
|
||||
v="-vv"
|
||||
else
|
||||
$memcached_prefix/bin/memcached -d -l $ip -m 4 -p $port
|
||||
mkdir -p $root/logs
|
||||
log="cat >>$root/logs/memcached"
|
||||
v=""
|
||||
fi
|
||||
|
||||
if [ "$ip" = "" ]; then
|
||||
($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 $v 2>&1 | $log)&
|
||||
fi
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
37
sca-cpp/trunk/components/sqldb/pgsql-log-conf
Executable file
37
sca-cpp/trunk/components/sqldb/pgsql-log-conf
Executable file
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue