summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-08-19 04:10:43 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-08-19 04:10:43 +0000
commit768a1e33e56c579edbcab1d4ea73d06b85cdd06c (patch)
tree5ea1f2c67ad34a17155c221711df7eff010034d2
parentd4184f1ab86fd589126f3de2ed9fa433cf1b54b2 (diff)
Script fixes to get database working with the HTTPS-enabled store-cluster sample configuration. Also some logging improvements and aggregation of the sample logs using scribe.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@987012 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--sca-cpp/trunk/components/log/Makefile.am13
-rw-r--r--sca-cpp/trunk/components/log/scribe-cat.cpp77
-rwxr-xr-xsca-cpp/trunk/components/log/scribe-tail-start (renamed from sca-cpp/trunk/components/log/scribe-cat)30
-rwxr-xr-x[-rw-r--r--]sca-cpp/trunk/components/log/scribe-tail-stop (renamed from sca-cpp/trunk/components/log/scribecat.py)46
-rwxr-xr-xsca-cpp/trunk/components/log/scribe-test2
-rwxr-xr-xsca-cpp/trunk/components/log/scribed-central-conf7
-rwxr-xr-xsca-cpp/trunk/components/log/scribed-client-conf9
-rwxr-xr-xsca-cpp/trunk/components/sqldb/pgsql-standby-conf24
-rwxr-xr-xsca-cpp/trunk/components/sqldb/standby-test2
-rw-r--r--sca-cpp/trunk/kernel/fstream.hpp98
-rw-r--r--sca-cpp/trunk/kernel/monad.hpp9
-rw-r--r--sca-cpp/trunk/kernel/stream.hpp2
-rwxr-xr-xsca-cpp/trunk/modules/http/httpd-conf2
-rwxr-xr-xsca-cpp/trunk/modules/http/httpd-ssl-conf9
-rw-r--r--sca-cpp/trunk/modules/http/httpd.hpp54
-rw-r--r--sca-cpp/trunk/modules/json/json.hpp4
-rw-r--r--sca-cpp/trunk/modules/server/mod-eval.hpp6
-rw-r--r--sca-cpp/trunk/modules/server/mod-wiring.cpp2
-rwxr-xr-xsca-cpp/trunk/samples/store-cluster/proxy-conf6
-rwxr-xr-xsca-cpp/trunk/samples/store-cluster/server-conf5
-rwxr-xr-xsca-cpp/trunk/samples/store-cluster/server-ssl-conf5
-rwxr-xr-xsca-cpp/trunk/samples/store-cluster/sqldb-master-conf12
-rwxr-xr-xsca-cpp/trunk/samples/store-cluster/sqldb-standby-conf20
-rwxr-xr-xsca-cpp/trunk/samples/store-cluster/ssl-start59
-rwxr-xr-xsca-cpp/trunk/samples/store-cluster/ssl-stop15
-rwxr-xr-xsca-cpp/trunk/samples/store-cluster/start36
-rwxr-xr-xsca-cpp/trunk/samples/store-cluster/stop5
-rwxr-xr-xsca-cpp/trunk/samples/store-cluster/tunnel-ssl-conf15
28 files changed, 455 insertions, 119 deletions
diff --git a/sca-cpp/trunk/components/log/Makefile.am b/sca-cpp/trunk/components/log/Makefile.am
index 0408607b59..614a13bcc5 100644
--- a/sca-cpp/trunk/components/log/Makefile.am
+++ b/sca-cpp/trunk/components/log/Makefile.am
@@ -22,17 +22,17 @@ INCLUDES = -I${THRIFT_INCLUDE} -I${FB303_INCLUDE}
incl_HEADERS = *.hpp
incldir = $(prefix)/include/components/log
-dist_comp_SCRIPTS = scribed-central-conf scribed-client-conf scribed-central-start scribed-central-stop scribed-client-start scribed-client-stop scribe-cat
+dist_comp_SCRIPTS = scribed-central-conf scribed-client-conf scribed-central-start scribed-central-stop scribed-client-start scribed-client-stop scribe-tail-start scribe-tail-stop
compdir=$(prefix)/components/log
-comp_DATA = scribe.prefix thrift.prefix scribecat.py
+comp_DATA = scribe.prefix thrift.prefix
scribe.prefix: $(top_builddir)/config.status
echo ${SCRIBE_PREFIX} >scribe.prefix
thrift.prefix: $(top_builddir)/config.status
echo ${THRIFT_PREFIX} >thrift.prefix
-EXTRA_DIST = log.composite *.py *.scm *.thrift
+EXTRA_DIST = log.composite *.scm *.thrift
BUILT_SOURCES=gen-cpp/fb303_constants.cpp gen-cpp/fb303_types.cpp gen-cpp/scribe_constants.cpp gen-cpp/scribe.cpp gen-cpp/scribe_types.cpp gen-cpp/FacebookService.cpp gen-cpp/scribe.h
gen-cpp/fb303_constants.cpp gen-cpp/fb303_types.cpp gen-cpp/scribe_constants.cpp gen-cpp/scribe.cpp gen-cpp/scribe_types.cpp gen-cpp/FacebookService.cpp gen-cpp/scribe.h: scribe.thrift
@@ -57,6 +57,13 @@ liblogger_la_LDFLAGS = -L${THRIFT_LIB} -R${THRIFT_LIB} -lthrift -L${FB303_LIB} -
liblogger.so:
ln -s .libs/liblogger.so
+comp_PROGRAMS = scribe-cat
+
+nodist_scribe_cat_SOURCES = gen-cpp/fb303_constants.cpp gen-cpp/fb303_types.cpp gen-cpp/scribe_constants.cpp gen-cpp/scribe.cpp gen-cpp/scribe_types.cpp gen-cpp/FacebookService.cpp gen-cpp/scribe.h
+scribe_cat_CXXFLAGS = -Wno-unused-parameter
+scribe_cat_SOURCES = scribe-cat.cpp
+scribe_cat_LDFLAGS = -L${THRIFT_LIB} -R${THRIFT_LIB} -lthrift -L${FB303_LIB} -R${FB303_LIB} -lfb303 -L${SCRIBE_LIB} -R${SCRIBE_LIB} -lscribe
+
client_test_SOURCES = client-test.cpp
client_test_LDFLAGS = -lxml2 -lcurl -lmozjs
diff --git a/sca-cpp/trunk/components/log/scribe-cat.cpp b/sca-cpp/trunk/components/log/scribe-cat.cpp
new file mode 100644
index 0000000000..f3c5e898cd
--- /dev/null
+++ b/sca-cpp/trunk/components/log/scribe-cat.cpp
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+/**
+ * A utility that logs stdin into a scribe log.
+ */
+
+#include "string.hpp"
+#include "function.hpp"
+#include "list.hpp"
+#include "value.hpp"
+#include "monad.hpp"
+
+#undef debug
+#define debug(...)
+#include "scribe.hpp"
+
+namespace tuscany {
+namespace scribecat {
+
+int cat(const string& category, const string& type) {
+ // Connect to Scribe
+ scribe::Scribe& sc = *(new (gc_new<scribe::Scribe>()) scribe::Scribe("localhost", 1464));
+
+ // Read lines from stdin and log them
+ char buf[8192];
+ for (;;) {
+ const char* s = fgets(buf, 8192, stdin);
+ if (s == NULL)
+ return 0;
+ const int l = strlen(s);
+ if (l < 2)
+ return 0;
+ buf[l - 1] = '\0';
+
+ // Log each line as is
+ if (length(type) == 0) {
+ const failable<bool> val = scribe::log(buf, category, sc);
+ if (!hasContent(val))
+ return 1;
+ continue;
+ }
+
+ // Log each line prefixed with time and a type tag
+ ostringstream os;
+ os << "[" << logTime() << "] [" << type << "] " << buf;
+ const failable<bool> val = scribe::log(c_str(str(os)), category, sc);
+ if (!hasContent(val))
+ return 1;
+ }
+}
+
+}
+}
+
+int main(const int argc, const char** argv) {
+ return tuscany::scribecat::cat(argc < 2? "default" : argv[1], argc < 3? "" : argv[2]);
+}
+
diff --git a/sca-cpp/trunk/components/log/scribe-cat b/sca-cpp/trunk/components/log/scribe-tail-start
index 812e7e7a54..0044f1620d 100755
--- a/sca-cpp/trunk/components/log/scribe-cat
+++ b/sca-cpp/trunk/components/log/scribe-tail-start
@@ -17,16 +17,28 @@
# specific language governing permissions and limitations
# under the License.
-# Write messages to Scribe
+# Tail a file and pipe into scribe-cat
here=`readlink -f $0`; here=`dirname $here`
-category=$1
-if [ "$category" = "" ]; then
- category="default"
+
+category=""
+type=""
+file=""
+if [ "$3" != "" ]; then
+ category=$1
+ type=$2
+ file=$3
+else
+ if [ "$2" != "" ]; then
+ category=$1
+ file=$2
+ else
+ file=$1
+ fi
fi
-python_prefix=`cat $here/../../modules/python/python.prefix`
-scribe_prefix=`cat $here/scribe.prefix`
-thrift_prefix=`cat $here/thrift.prefix`
-export PYTHONPATH=$PYTHONPATH:${thrift_prefix}/lib/python2.6/site-packages:${thrift_prefix}/contrib/fb303/lib/python2.6/site-packages:${scribe_prefix}/lib/python2.6/site-packages
-$python_prefix/bin/python $here/scribecat.py $category
+mkdir -p `dirname $file`
+touch $file
+file=`readlink -f $file`
+
+tail -f -n 0 $file | $here/scribe-cat $category $type &
diff --git a/sca-cpp/trunk/components/log/scribecat.py b/sca-cpp/trunk/components/log/scribe-tail-stop
index b0fef42fbf..e1b74fc0c6 100644..100755
--- a/sca-cpp/trunk/components/log/scribecat.py
+++ b/sca-cpp/trunk/components/log/scribe-tail-stop
@@ -1,3 +1,5 @@
+#!/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
@@ -15,30 +17,26 @@
# specific language governing permissions and limitations
# under the License.
-# Write messages to Scribe
-
-import sys
-from scribe import scribe
-from thrift.transport import TTransport, TSocket
-from thrift.protocol import TBinaryProtocol
-
-category = sys.argv[1]
-host = 'localhost'
-port = 1464
+# Stop tailing a file
+here=`readlink -f $0`; here=`dirname $here`
-entry = scribe.LogEntry(category=category, message=sys.stdin.read())
-socket = TSocket.TSocket(host=host, port=port)
-transport = TTransport.TFramedTransport(socket)
-protocol = TBinaryProtocol.TBinaryProtocol(trans=transport, strictRead=False, strictWrite=False)
-client = scribe.Client(iprot=protocol, oprot=protocol)
-transport.open()
-result = client.Log(messages=[entry])
-transport.close()
+category=""
+type=""
+file=""
+if [ "$3" != "" ]; then
+ category=$1
+ type=$2
+ file=$3
+else
+ if [ "$2" != "" ]; then
+ category=$1
+ file=$2
+ else
+ file=$1
+ fi
+fi
+file=`readlink -f $file`
-if result == scribe.ResultCode.OK:
- sys.exit()
-if result == scribe.ResultCode.TRY_LATER:
- print >> sys.stderr, "Try later"
- sys.exit(84)
-sys.exit(result)
+cmd="tail -f -n 0 $file"
+kill `ps -ef | grep -v grep | grep "${cmd}" | awk '{ print $2 }'`
diff --git a/sca-cpp/trunk/components/log/scribe-test b/sca-cpp/trunk/components/log/scribe-test
index 1c76b2eb58..a355026dd0 100755
--- a/sca-cpp/trunk/components/log/scribe-test
+++ b/sca-cpp/trunk/components/log/scribe-test
@@ -28,7 +28,7 @@ rm -rf tmp
sleep 1
# Test logging a message
-echo test | ./scribe-cat
+echo test | ./scribe-cat >/dev/null
sleep 4
grep test tmp/scribe/logs/central/default/default_current >/dev/null
rc=$?
diff --git a/sca-cpp/trunk/components/log/scribed-central-conf b/sca-cpp/trunk/components/log/scribed-central-conf
index 3bb9c29c85..b23646c24f 100755
--- a/sca-cpp/trunk/components/log/scribed-central-conf
+++ b/sca-cpp/trunk/components/log/scribed-central-conf
@@ -22,6 +22,11 @@ here=`readlink -f $0`; here=`dirname $here`
mkdir -p $1
root=`readlink -f $1`
+port=$2
+if [ "$port" = "" ]; then
+ port="1463"
+fi
+
mkdir -p $root/scribe/conf
mkdir -p $root/scribe/logs/central
mkdir -p $root/scribe/logs/central-secondary
@@ -29,7 +34,7 @@ mkdir -p $root/scribe/logs/central-secondary
cat >$root/scribe/conf/scribe-central.conf <<EOF
# Generated by: scribed-central-conf $*
# Scribe central configuration
-port=1463
+port=$port
max_msg_per_second=2000000
check_interval=3
diff --git a/sca-cpp/trunk/components/log/scribed-client-conf b/sca-cpp/trunk/components/log/scribed-client-conf
index 3300e4e5ec..87c8749c2e 100755
--- a/sca-cpp/trunk/components/log/scribed-client-conf
+++ b/sca-cpp/trunk/components/log/scribed-client-conf
@@ -21,7 +21,12 @@
here=`readlink -f $0`; here=`dirname $here`
mkdir -p $1
root=`readlink -f $1`
+
central=$2
+cport=$3
+if [ "$cport" = "" ]; then
+ cport="1463"
+fi
mkdir -p $root/scribe/conf
mkdir -p $root/scribe/logs/client-secondary
@@ -47,8 +52,8 @@ retry_interval_range=10
<primary>
type=network
-remote_host=$2
-remote_port=1463
+remote_host=$central
+remote_port=$cport
</primary>
<secondary>
diff --git a/sca-cpp/trunk/components/sqldb/pgsql-standby-conf b/sca-cpp/trunk/components/sqldb/pgsql-standby-conf
index 3b4aa6dff5..cbfd90b48c 100755
--- a/sca-cpp/trunk/components/sqldb/pgsql-standby-conf
+++ b/sca-cpp/trunk/components/sqldb/pgsql-standby-conf
@@ -22,19 +22,8 @@ here=`readlink -f $0`; here=`dirname $here`
mkdir -p $1
root=`readlink -f $1`
-# Master server address
-if [ "$2" = "" ]; then
- mhost="localhost"
- mport="5432"
- mhttpport="80"
-else
- mhost="$2"
- mport="$3"
- mhttpport="$4"
-fi
-
# Server address
-addr=$5
+addr=$2
if [ "$addr" = "" ]; then
ip="*"
port="5432"
@@ -46,6 +35,17 @@ else
port=`$here/../../modules/http/httpd-addr port $addr`
fi
+# Master server address
+if [ "$3" = "" ]; then
+ mhost="localhost"
+ mport="5432"
+ mhttpport="80"
+else
+ mhost="$3"
+ mport="$4"
+ mhttpport="$5"
+fi
+
pgsql_prefix=`cat $here/pgsql.prefix`
mkdir -p $root/sqldb/data
chmod 700 $root/sqldb/data
diff --git a/sca-cpp/trunk/components/sqldb/standby-test b/sca-cpp/trunk/components/sqldb/standby-test
index e572de6fe2..9e56bfc039 100755
--- a/sca-cpp/trunk/components/sqldb/standby-test
+++ b/sca-cpp/trunk/components/sqldb/standby-test
@@ -25,7 +25,7 @@
./pgsql localhost 5432 "create table test(key text, value text);" 1>/dev/null 2>&1
../../modules/http/httpd-start tmp/master
sleep 2
-./pgsql-standby-conf tmp/standby localhost 5432 8090 5433
+./pgsql-standby-conf tmp/standby 5433 localhost 5432 8090
./pgsql-start tmp/standby
# Test
diff --git a/sca-cpp/trunk/kernel/fstream.hpp b/sca-cpp/trunk/kernel/fstream.hpp
index f5a9dcd981..033024de1d 100644
--- a/sca-cpp/trunk/kernel/fstream.hpp
+++ b/sca-cpp/trunk/kernel/fstream.hpp
@@ -28,6 +28,7 @@
#include <stdio.h>
#include <stdarg.h>
+#include <time.h>
#include "string.hpp"
#include "stream.hpp"
@@ -137,20 +138,107 @@ ofstream cerr(stderr);
ifstream cin(stdin);
/**
- * Debug log stream.
+ * Streams used for logging.
*/
+
+/**
+ * Format the current time.
+ */
+const string logTime() {
+ const time_t t = ::time(NULL);
+ const tm* lt = localtime(&t);
+ char ft[32];
+ strftime(ft, 31, "%a %b %d %H:%M:%S %Y", lt);
+ return ft;
+}
+
+/*
+ * Log stream.
+ */
+class logfstream : public ostream {
+public:
+ logfstream(FILE* file, const string& type) : file(file), type(type), owner(false), head(false) {
+ }
+
+ logfstream(const logfstream& os) : file(os.file), type(type), owner(false), head(os.head) {
+ }
+
+ ~logfstream() {
+ if (!owner)
+ return;
+ if (file == NULL)
+ return;
+ fclose(file);
+ }
+
+ logfstream& vprintf(const char* fmt, ...) {
+ whead();
+ va_list args;
+ va_start (args, fmt);
+ vfprintf (file, fmt, args);
+ va_end (args);
+ return *this;
+ }
+
+ logfstream& write(const string& s) {
+ whead();
+ fwrite(c_str(s), 1, length(s), file);
+ if (s == "\n")
+ head = false;
+ return *this;
+ }
+
+ logfstream& flush() {
+ fflush(file);
+ return *this;
+ }
+
+private:
+ FILE* file;
+ const string type;
+ bool owner;
+ bool head;
+
+ logfstream& whead() {
+ if (head)
+ return *this;
+ head = true;
+ *this << "[" << logTime() << "] [" << type << "] ";
+ return *this;
+ }
+};
+
+/**
+ * Info and failure log streams.
+ */
+logfstream cinfo(stderr, "info");
+logfstream cfailure(stderr, "error");
+
#ifdef WANT_MAINTAINER_MODE
-template<typename V> const bool debug(const V& v, const string& msg) {
- cerr << msg << ": " << v << endl;
+/**
+ * Debug log stream and debug functions.
+ */
+logfstream cdebug(stderr, "debug");
+
+/**
+ * Log a debug message.
+ */
+const bool debugLog(const string& msg) {
+ cdebug << msg << endl;
return true;
}
-const bool debug(const string& msg) {
- cerr << msg << endl;
+/**
+ * Log a debug message and a value.
+ */
+template<typename V> const bool debugLog(const V& v, const string& msg) {
+ cdebug << msg << ": " << v << endl;
return true;
}
+#define debug(...) tuscany::debugLog(__VA_ARGS__)
+
#else
#define debug(...)
diff --git a/sca-cpp/trunk/kernel/monad.hpp b/sca-cpp/trunk/kernel/monad.hpp
index 8aa4bc1662..d87a382ee1 100644
--- a/sca-cpp/trunk/kernel/monad.hpp
+++ b/sca-cpp/trunk/kernel/monad.hpp
@@ -29,6 +29,8 @@
#include "function.hpp"
#include "string.hpp"
#include "stream.hpp"
+#include "sstream.hpp"
+#include "fstream.hpp"
namespace tuscany
{
@@ -275,7 +277,12 @@ template<typename V, typename F> const lambda<failable<V, F>(const V)> success()
* Returns a failable monad with a failure in it.
*/
template<typename V, typename F> const failable<V, F> mkfailure(const F& f) {
- debug(f, "failable::mkfailure");
+#ifdef WANT_MAINTAINER_MODE
+ ostringstream os;
+ os << f;
+ if (length(str(os)) != 0)
+ debug(f, "failable::mkfailure");
+#endif
return failable<V, F>(false, f);
}
diff --git a/sca-cpp/trunk/kernel/stream.hpp b/sca-cpp/trunk/kernel/stream.hpp
index 32b754f315..f9d5cc3afe 100644
--- a/sca-cpp/trunk/kernel/stream.hpp
+++ b/sca-cpp/trunk/kernel/stream.hpp
@@ -97,7 +97,7 @@ class stream_endl {
} endl;
ostream& operator<<(ostream& os, unused const stream_endl e) {
- os.vprintf("%s", "\n");
+ os.write("\n");
return os.flush();
}
diff --git a/sca-cpp/trunk/modules/http/httpd-conf b/sca-cpp/trunk/modules/http/httpd-conf
index 9f698688b1..4a094bbacf 100755
--- a/sca-cpp/trunk/modules/http/httpd-conf
+++ b/sca-cpp/trunk/modules/http/httpd-conf
@@ -92,7 +92,7 @@ HostNameLookups Off
# Log HTTP requests
LogLevel info
ErrorLog $root/logs/error_log
-LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined
+LogFormat "[%{%a %b %d %H:%M:%S %Y}t] [access] %h %l %u \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined
CustomLog $root/logs/access_log combined
# Configure Mime types
diff --git a/sca-cpp/trunk/modules/http/httpd-ssl-conf b/sca-cpp/trunk/modules/http/httpd-ssl-conf
index da66733f9e..a6da987345 100755
--- a/sca-cpp/trunk/modules/http/httpd-ssl-conf
+++ b/sca-cpp/trunk/modules/http/httpd-ssl-conf
@@ -24,6 +24,9 @@ root=`readlink -f $1`
conf=`cat $root/conf/httpd.conf | grep "# Generated by: httpd-conf"`
host=`echo $conf | awk '{ print $6 }'`
+gport=`echo $conf | awk '{ print $7 }'`
+port=`$here/httpd-addr port $gport`
+pport=`$here/httpd-addr pport $gport`
sslpport=`$here/httpd-addr pport $2`
ssllisten=`$here/httpd-addr listen $2`
@@ -44,7 +47,8 @@ cat >>$root/conf/httpd.conf <<EOF
# Redirect all HTTP traffic to HTTPS
<Location />
RewriteEngine on
-RewriteCond %{HTTPS} !^on$
+RewriteCond %{SERVER_PORT} ^$port$ [OR]
+RewriteCond %{SERVER_PORT} ^$pport$
RewriteRule .* https://%{SERVER_NAME}:$sslpport%{REQUEST_URI} [R,L]
</Location>
@@ -99,8 +103,7 @@ SSLVerifyClient optional
SSLVerifyDepth 1
# Log SSL requests
-#CustomLog "$root/logs/ssl_request_log" "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
-LogFormat "%h %l %u %t %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\" \"%{SSL_CLIENT_I_DN}x\" \"%{SSL_CLIENT_S_DN}x\"" sslcombined
+LogFormat "[%{%a %b %d %H:%M:%S %Y}t] [sslaccess] %h %l %u %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\" \"%{SSL_CLIENT_I_DN}x\" \"%{SSL_CLIENT_S_DN}x\"" sslcombined
CustomLog $root/logs/ssl_access_log sslcombined
EOF
diff --git a/sca-cpp/trunk/modules/http/httpd.hpp b/sca-cpp/trunk/modules/http/httpd.hpp
index 767af11cf9..ef89cbda0a 100644
--- a/sca-cpp/trunk/modules/http/httpd.hpp
+++ b/sca-cpp/trunk/modules/http/httpd.hpp
@@ -43,6 +43,7 @@
#include <util_script.h>
#include <util_md5.h>
#include <http_config.h>
+#include <http_log.h>
#include <ap_mpm.h>
#include <mod_core.h>
@@ -50,6 +51,7 @@
#include "stream.hpp"
#include "list.hpp"
#include "value.hpp"
+#include "monad.hpp"
namespace tuscany {
@@ -408,44 +410,60 @@ const void* userData(const string& k, const server_rec* s) {
/**
* Debug log.
*/
+
+/**
+ * Log an optional value.
+ */
const char* debugOptional(const char* s) {
if (s == NULL)
return "";
return s;
}
+/**
+ * Log a header
+ */
int debugHeader(unused void* r, const char* key, const char* value) {
- cerr << " header key: " << key << ", value: " << value << endl;
+ cdebug << " header key: " << key << ", value: " << value << endl;
return 1;
}
+/**
+ * Log an environment variable
+ */
int debugEnv(unused void* r, const char* key, const char* value) {
- cerr << " var key: " << key << ", value: " << value << endl;
+ cdebug << " var key: " << key << ", value: " << value << endl;
return 1;
}
+/**
+ * Log a note.
+ */
int debugNote(unused void* r, const char* key, const char* value) {
- cerr << " note key: " << key << ", value: " << value << endl;
+ cdebug << " note key: " << key << ", value: " << value << endl;
return 1;
}
+/**
+ * Log a request.
+ */
const bool debugRequest(request_rec* r, const string& msg) {
- cerr << msg << ":" << endl;
- cerr << " server: " << debugOptional(r->server->server_hostname) << endl;
- cerr << " protocol: " << debugOptional(r->protocol) << endl;
- cerr << " method: " << debugOptional(r->method) << endl;
- cerr << " method number: " << r->method_number << endl;
- cerr << " content type: " << contentType(r) << endl;
- cerr << " content encoding: " << debugOptional(r->content_encoding) << endl;
+ cdebug << msg << ":" << endl;
+ cdebug << " server: " << debugOptional(r->server->server_hostname) << endl;
+ cdebug << " protocol: " << debugOptional(r->protocol) << endl;
+ cdebug << " method: " << debugOptional(r->method) << endl;
+ cdebug << " method number: " << r->method_number << endl;
+ cdebug << " content type: " << contentType(r) << endl;
+ cdebug << " content encoding: " << debugOptional(r->content_encoding) << endl;
apr_table_do(debugHeader, r, r->headers_in, NULL);
- cerr << " unparsed uri: " << debugOptional(r->unparsed_uri) << endl;
- cerr << " uri: " << debugOptional(r->uri) << endl;
- cerr << " path info: " << debugOptional(r->path_info) << endl;
- cerr << " filename: " << debugOptional(r->filename) << endl;
- cerr << " uri tokens: " << pathTokens(r->uri) << endl;
- cerr << " args: " << debugOptional(r->args) << endl;
- cerr << " user: " << debugOptional(r->user) << endl;
- cerr << " auth type: " << debugOptional(r->ap_auth_type) << endl;
+ cdebug << " unparsed uri: " << debugOptional(r->unparsed_uri) << endl;
+ cdebug << " uri: " << debugOptional(r->uri) << endl;
+ cdebug << " path info: " << debugOptional(r->path_info) << endl;
+ cdebug << " filename: " << debugOptional(r->filename) << endl;
+ cdebug << " uri tokens: " << pathTokens(r->uri) << endl;
+ cdebug << " args: " << debugOptional(r->args) << endl;
+ cdebug << " user: " << debugOptional(r->user) << endl;
+ cdebug << " auth type: " << debugOptional(r->ap_auth_type) << endl;
apr_table_do(debugEnv, r, r->subprocess_env, NULL);
apr_table_do(debugEnv, r, r->notes, NULL);
return true;
diff --git a/sca-cpp/trunk/modules/json/json.hpp b/sca-cpp/trunk/modules/json/json.hpp
index 4e02cbf2c9..f904718f05 100644
--- a/sca-cpp/trunk/modules/json/json.hpp
+++ b/sca-cpp/trunk/modules/json/json.hpp
@@ -41,8 +41,10 @@ namespace json {
* Report JSON errors.
*/
void reportError(unused JSContext *cx, const char *message, JSErrorReport *report) {
- cerr << (const char*)(report->filename? report->filename : "<no filename>") << ":"
+#ifdef WANT_MAINTAINER_MODE
+ cdebug << (const char*)(report->filename? report->filename : "<no filename>") << ":"
<< (int)report->lineno << ":" << message << endl;
+#endif
}
/**
diff --git a/sca-cpp/trunk/modules/server/mod-eval.hpp b/sca-cpp/trunk/modules/server/mod-eval.hpp
index 0d90cb7ceb..391f5b8325 100644
--- a/sca-cpp/trunk/modules/server/mod-eval.hpp
+++ b/sca-cpp/trunk/modules/server/mod-eval.hpp
@@ -671,7 +671,7 @@ int postConfig(apr_pool_t *p, unused apr_pool_t *plog, unused apr_pool_t *ptemp,
// Configure the deployed components
const failable<bool> res = confComponents(sc);
if (!hasContent(res)) {
- cerr << "[Tuscany] Due to one or more errors mod_tuscany_eval loading failed. Causing apache to stop loading." << endl;
+ cfailure << "[Tuscany] Due to one or more errors mod_tuscany_eval loading failed. Causing apache to stop loading." << endl;
return -1;
}
@@ -689,14 +689,14 @@ void childInit(apr_pool_t* p, server_rec* s) {
gc_scoped_pool pool(p);
ServerConf* sc = (ServerConf*)ap_get_module_config(s->module_config, &mod_tuscany_eval);
if(sc == NULL) {
- cerr << "[Tuscany] Due to one or more errors mod_tuscany_eval loading failed. Causing apache to stop loading." << endl;
+ cfailure << "[Tuscany] Due to one or more errors mod_tuscany_eval loading failed. Causing apache to stop loading." << endl;
exit(APEXIT_CHILDFATAL);
}
// Start the components in the child process
const failable<bool> res = startComponents(*sc);
if (!hasContent(res)) {
- cerr << "[Tuscany] Due to one or more errors mod_tuscany_eval loading failed. Causing apache to stop loading." << endl;
+ cfailure << "[Tuscany] Due to one or more errors mod_tuscany_eval loading failed. Causing apache to stop loading." << endl;
exit(APEXIT_CHILDFATAL);
}
diff --git a/sca-cpp/trunk/modules/server/mod-wiring.cpp b/sca-cpp/trunk/modules/server/mod-wiring.cpp
index 7ed47c7f48..32217172fd 100644
--- a/sca-cpp/trunk/modules/server/mod-wiring.cpp
+++ b/sca-cpp/trunk/modules/server/mod-wiring.cpp
@@ -396,7 +396,7 @@ void childInit(apr_pool_t* p, server_rec* s) {
gc_scoped_pool pool(p);
ServerConf *conf = (ServerConf*)ap_get_module_config(s->module_config, &mod_tuscany_wiring);
if(conf == NULL) {
- cerr << "[Tuscany] Due to one or more errors mod_tuscany_wiring loading failed. Causing apache to stop loading." << endl;
+ cfailure << "[Tuscany] Due to one or more errors mod_tuscany_wiring loading failed. Causing apache to stop loading." << endl;
exit(APEXIT_CHILDFATAL);
}
}
diff --git a/sca-cpp/trunk/samples/store-cluster/proxy-conf b/sca-cpp/trunk/samples/store-cluster/proxy-conf
index bdfee78917..a72629d140 100755
--- a/sca-cpp/trunk/samples/store-cluster/proxy-conf
+++ b/sca-cpp/trunk/samples/store-cluster/proxy-conf
@@ -24,3 +24,9 @@ port=$2
../../modules/http/httpd-conf $root sca-store.com $port/80 $root/htdocs
../../modules/http/vhost-conf $root
../../modules/http/proxy-conf $root
+
+# Aggregate proxy balancer logs
+category=`basename $root`
+../../components/log/scribe-tail-start $category $root/logs/error_log
+../../components/log/scribe-tail-start $category $root/logs/access_log
+
diff --git a/sca-cpp/trunk/samples/store-cluster/server-conf b/sca-cpp/trunk/samples/store-cluster/server-conf
index 0aeb39813d..66b9639eeb 100755
--- a/sca-cpp/trunk/samples/store-cluster/server-conf
+++ b/sca-cpp/trunk/samples/store-cluster/server-conf
@@ -32,3 +32,8 @@ SCAVirtualComposite store.composite
EOF
+# Aggregate app server logs
+category=`basename $root`
+../../components/log/scribe-tail-start $category $root/logs/error_log
+../../components/log/scribe-tail-start $category $root/logs/access_log
+
diff --git a/sca-cpp/trunk/samples/store-cluster/server-ssl-conf b/sca-cpp/trunk/samples/store-cluster/server-ssl-conf
index 35c83f8d65..39fe830f19 100755
--- a/sca-cpp/trunk/samples/store-cluster/server-ssl-conf
+++ b/sca-cpp/trunk/samples/store-cluster/server-ssl-conf
@@ -38,3 +38,8 @@ SCAVirtualComposite store.composite
EOF
+# Aggregate app server logs
+category=`basename $root`
+../../components/log/scribe-tail-start $category $root/logs/error_log
+../../components/log/scribe-tail-start $category $root/logs/access_log
+
diff --git a/sca-cpp/trunk/samples/store-cluster/sqldb-master-conf b/sca-cpp/trunk/samples/store-cluster/sqldb-master-conf
index cd85f1e328..f191b4eb3e 100755
--- a/sca-cpp/trunk/samples/store-cluster/sqldb-master-conf
+++ b/sca-cpp/trunk/samples/store-cluster/sqldb-master-conf
@@ -19,6 +19,16 @@
root=$1
port=$2
+httpport=$3
+
+# Aggregate database server logs
+category=`basename $root`
+../../components/log/scribe-tail-start $category "sqldb" $root/logs/postgresql
+../../components/log/scribe-tail-start $category $root/logs/error_log
+../../components/log/scribe-tail-start $category $root/logs/access_log
+
+# Configure a database backup HTTP server
+../../modules/http/httpd-conf $root localhost $httpport $root/htdocs
# Configure a database server
if [ ! -f $root/sqldb/data/postgresql.conf ]; then
@@ -29,7 +39,7 @@ fi
../../components/sqldb/pgsql-conf $root $port
if [ "$create" = "true" ]; then
../../components/sqldb/pgsql-start $root
- ../../components/sqldb/pgsql localhost $port "create table store(key text, value text);" 1>/dev/null 2>&1
+ ../../components/sqldb/pgsql localhost $port "create table store(key text, value text);" 1>>$root/logs/postgresql 2>&1
../../components/sqldb/pgsql-stop $root
fi
diff --git a/sca-cpp/trunk/samples/store-cluster/sqldb-standby-conf b/sca-cpp/trunk/samples/store-cluster/sqldb-standby-conf
index d1dec9930b..a3f3808346 100755
--- a/sca-cpp/trunk/samples/store-cluster/sqldb-standby-conf
+++ b/sca-cpp/trunk/samples/store-cluster/sqldb-standby-conf
@@ -18,11 +18,21 @@
# under the License.
root=$1
-mhost=$2
-mport=$3
-mhttpport=$4
-port=$5
+port=$2
+httpport=$3
+mhost=$4
+mport=$5
+mhttpport=$6
+
+# Aggregate database server logs
+category=`basename $root`
+../../components/log/scribe-tail-start $category "sqldb" $root/logs/postgresql
+../../components/log/scribe-tail-start $category $root/logs/error_log
+../../components/log/scribe-tail-start $category $root/logs/access_log
+
+# Configure a database backup HTTP server
+../../modules/http/httpd-conf $root localhost $httpport $root/htdocs
# Configure a standby database server
-../../components/sqldb/pgsql-standby-conf $root $mhost $mport $mhttpport $port
+../../components/sqldb/pgsql-standby-conf $root $port $mhost $mport $mhttpport
diff --git a/sca-cpp/trunk/samples/store-cluster/ssl-start b/sca-cpp/trunk/samples/store-cluster/ssl-start
index 8fe0af41d3..1347d524a8 100755
--- a/sca-cpp/trunk/samples/store-cluster/ssl-start
+++ b/sca-cpp/trunk/samples/store-cluster/ssl-start
@@ -17,6 +17,8 @@
# specific language governing permissions and limitations
# under the License.
+set -x
+
# Generate SSL certificates
../../modules/http/ssl-ca-conf tmp/ssl sca-store.com
../../modules/http/ssl-cert-conf tmp/ssl sca-store.com server
@@ -24,22 +26,65 @@
../../modules/http/ssl-cert-conf tmp/ssl sca-store.com proxy
../../modules/http/ssl-cert-conf tmp/ssl sca-store.com tunnel
-# Start three memcached servers and a tunnel server
+# Start an SSL tunnel
+./tunnel-ssl-conf tmp/tunnel 8119 8563
+../../modules/http/httpd-start tmp/tunnel
+sleep 1
+
+# Start scribe logging
+../../modules/http/tunnel-ssl-conf tmp/tunnel 1465 localhost 563 1463
+../../modules/http/httpd-restart tmp/tunnel
+../../components/log/scribed-central-conf tmp/monitor
+../../components/log/scribed-client-conf tmp/monitor localhost 1465
+../../components/log/scribed-central-start tmp/monitor
+../../components/log/scribed-client-start tmp/monitor
+sleep 1
+
+# Start three memcached servers
+../../modules/http/tunnel-ssl-conf tmp/tunnel 11211 localhost 563 11411
../../components/cache/memcached-start 127.0.0.1:11411
+../../modules/http/tunnel-ssl-conf tmp/tunnel 11212 localhost 563 11412
../../components/cache/memcached-start 127.0.0.1:11412
+../../modules/http/tunnel-ssl-conf tmp/tunnel 11213 localhost 563 11413
../../components/cache/memcached-start 127.0.0.1:11413
-./tunnel-ssl-conf tmp/tunnel1
-../../modules/http/httpd-start tmp/tunnel1
+../../modules/http/httpd-restart tmp/tunnel
+sleep 1
+
+# Start a master and two hot standby databases
+../../modules/http/tunnel-ssl-conf tmp/tunnel 5432 localhost 563 5532
+../../modules/http/tunnel-ssl-conf tmp/tunnel 8502 localhost 563 8602
+../../modules/http/httpd-restart tmp/tunnel
+./sqldb-master-conf tmp/sqldb1 127.0.0.1:5532 127.0.0.1:8602
+../../components/sqldb/pgsql-start tmp/sqldb1
+../../modules/http/httpd-start tmp/sqldb1
+sleep 1
+
+../../modules/http/tunnel-ssl-conf tmp/tunnel 5433 localhost 563 5533
+../../modules/http/tunnel-ssl-conf tmp/tunnel 8503 localhost 563 8603
+../../modules/http/httpd-restart tmp/tunnel
+./sqldb-standby-conf tmp/sqldb2 127.0.0.1:5533 127.0.0.1:8603 localhost 5432 8502
+../../components/sqldb/pgsql-start tmp/sqldb2
+../../modules/http/httpd-start tmp/sqldb2
+
+../../modules/http/tunnel-ssl-conf tmp/tunnel 5434 localhost 563 5534
+../../modules/http/tunnel-ssl-conf tmp/tunnel 8504 localhost 563 8604
+../../modules/http/httpd-restart tmp/tunnel
+./sqldb-standby-conf tmp/sqldb3 127.0.0.1:5534 127.0.0.1:8604 localhost 5432 8502
+../../components/sqldb/pgsql-start tmp/sqldb3
+../../modules/http/httpd-start tmp/sqldb3
# Start three app servers
./server-ssl-conf tmp/server1 8101 8441
../../modules/http/httpd-start tmp/server1
+sleep 1
./server-ssl-conf tmp/server2 8102 8442
../../modules/http/httpd-start tmp/server2
+sleep 1
./server-ssl-conf tmp/server3 8103 8443
../../modules/http/httpd-start tmp/server3
+sleep 1
# Start two proxy balancers
./proxy-ssl-conf tmp/proxy1 8091 8093
@@ -60,11 +105,15 @@
../../modules/http/proxy-ssl-member-conf tmp/proxy2 localhost 8443
../../modules/http/httpd-start tmp/proxy2
-# Redirect traffic from port 80 to 8091 and use proxy1
+# Redirect traffic from ports 80 and 443 to proxy1
#../../ubuntu/ip-redirect-all 80 8091
#../../ubuntu/ip-redirect-all 443 8093
-# Redirect traffic from port 80 to 8092 and use proxy2
+# Redirect traffic from ports 80 and 443 to proxy2
#../../ubuntu/ip-redirect-all 80 8092
#../../ubuntu/ip-redirect-all 443 8094
+# Redirect traffic from ports 119 and 563 to tunnel
+#../../ubuntu/ip-redirect-all 119 8119
+#../../ubuntu/ip-redirect-all 563 8563
+
diff --git a/sca-cpp/trunk/samples/store-cluster/ssl-stop b/sca-cpp/trunk/samples/store-cluster/ssl-stop
index 3c52c60399..ff36721315 100755
--- a/sca-cpp/trunk/samples/store-cluster/ssl-stop
+++ b/sca-cpp/trunk/samples/store-cluster/ssl-stop
@@ -17,6 +17,8 @@
# specific language governing permissions and limitations
# under the License.
+set -x
+
../../modules/http/httpd-stop tmp/server1
../../modules/http/httpd-stop tmp/server2
../../modules/http/httpd-stop tmp/server3
@@ -28,4 +30,15 @@
../../components/cache/memcached-stop 127.0.0.1:11412
../../components/cache/memcached-stop 127.0.0.1:11413
-../../modules/http/httpd-stop tmp/tunnel1
+../../components/sqldb/pgsql-stop tmp/sqldb3
+../../modules/http/httpd-stop tmp/sqldb3
+../../components/sqldb/pgsql-stop tmp/sqldb2
+../../modules/http/httpd-stop tmp/sqldb2
+../../components/sqldb/pgsql-stop tmp/sqldb1
+../../modules/http/httpd-stop tmp/sqldb1
+
+../../modules/http/httpd-stop tmp/tunnel
+
+../../components/log/scribed-client-stop tmp/monitor
+../../components/log/scribed-central-stop tmp/monitor
+../../components/log/scribe-tail-stop tmp
diff --git a/sca-cpp/trunk/samples/store-cluster/start b/sca-cpp/trunk/samples/store-cluster/start
index 2b3afc320c..3b8cc673e7 100755
--- a/sca-cpp/trunk/samples/store-cluster/start
+++ b/sca-cpp/trunk/samples/store-cluster/start
@@ -17,28 +17,44 @@
# specific language governing permissions and limitations
# under the License.
+set -x
+
+# Start scribe logging
+../../components/log/scribed-central-conf tmp/monitor
+../../components/log/scribed-client-conf tmp/monitor localhost
+../../components/log/scribed-central-start tmp/monitor
+../../components/log/scribed-client-start tmp/monitor
+sleep 1
+
# Start three memcached servers
../../components/cache/memcached-start 11211
../../components/cache/memcached-start 11212
../../components/cache/memcached-start 11213
-# Start three app servers, with a master database and
-# two hot standby databases
+# Start a master and two hot standby databases
+./sqldb-master-conf tmp/sqldb1 5432 8502
+../../components/sqldb/pgsql-start tmp/sqldb1
+../../modules/http/httpd-start tmp/sqldb1
+sleep 1
+
+./sqldb-standby-conf tmp/sqldb2 5433 8503 localhost 5432 8502
+../../components/sqldb/pgsql-start tmp/sqldb2
+../../modules/http/httpd-start tmp/sqldb2
+
+./sqldb-standby-conf tmp/sqldb3 5434 8504 localhost 5432 8502
+../../components/sqldb/pgsql-start tmp/sqldb3
+../../modules/http/httpd-start tmp/sqldb3
+
+# Start three app servers
./server-conf tmp/server1 8101
-./sqldb-master-conf tmp/server1 5432
-../../components/sqldb/pgsql-start tmp/server1
../../modules/http/httpd-start tmp/server1
sleep 1
./server-conf tmp/server2 8102
-./sqldb-standby-conf tmp/server2 localhost 5432 8101 5433
-../../components/sqldb/pgsql-start tmp/server2
../../modules/http/httpd-start tmp/server2
sleep 1
./server-conf tmp/server3 8103
-./sqldb-standby-conf tmp/server3 localhost 5432 8101 5434
-../../components/sqldb/pgsql-start tmp/server3
../../modules/http/httpd-start tmp/server3
sleep 1
@@ -55,9 +71,9 @@ sleep 1
../../modules/http/proxy-member-conf tmp/proxy2 localhost 8103
../../modules/http/httpd-start tmp/proxy2
-# Redirect traffic from port 80 to 8091 and use proxy1
+# Redirect traffic from port 80 to proxy1
#../../ubuntu/ip-redirect-all 80 8091
-# Redirect traffic from port 80 to 8092 and use proxy2
+# Redirect traffic from port 80 to proxy2
#../../ubuntu/ip-redirect-all 80 8092
diff --git a/sca-cpp/trunk/samples/store-cluster/stop b/sca-cpp/trunk/samples/store-cluster/stop
index d3d29f9cb2..4a6de4ffd7 100755
--- a/sca-cpp/trunk/samples/store-cluster/stop
+++ b/sca-cpp/trunk/samples/store-cluster/stop
@@ -17,6 +17,8 @@
# specific language governing permissions and limitations
# under the License.
+set -x
+
../../components/sqldb/pgsql-stop tmp/server2
../../components/sqldb/pgsql-stop tmp/server3
../../components/sqldb/pgsql-stop tmp/server1
@@ -32,3 +34,6 @@
../../components/cache/memcached-stop 11212
../../components/cache/memcached-stop 11213
+../../components/log/scribed-client-stop tmp/monitor
+../../components/log/scribed-central-stop tmp/monitor
+../../components/log/scribe-tail-stop tmp
diff --git a/sca-cpp/trunk/samples/store-cluster/tunnel-ssl-conf b/sca-cpp/trunk/samples/store-cluster/tunnel-ssl-conf
index bbaf511e51..1b70a5d2c8 100755
--- a/sca-cpp/trunk/samples/store-cluster/tunnel-ssl-conf
+++ b/sca-cpp/trunk/samples/store-cluster/tunnel-ssl-conf
@@ -18,16 +18,11 @@
# under the License.
root=$1
+port=$2
+sslport=$3
-# Configure SSL tunnels to the memcached servers
-../../modules/http/httpd-conf $root localhost 127.0.0.1:11210 htdocs
+# Configure an SSL-enabled tunnel server
+../../modules/http/httpd-conf $root sca-store.com $port/119 $root/htdocs
tar -C tmp/ssl -c `../../modules/http/ssl-cert-find tmp/ssl` | tar -C $root -x
-../../modules/http/tunnel-ssl-conf $root 11211 localhost 8441 11411
-../../modules/http/tunnel-ssl-conf $root 11212 localhost 8442 11412
-../../modules/http/tunnel-ssl-conf $root 11213 localhost 8443 11413
-
-# Configure SSL tunnels to the postgresql servers
-../../modules/http/tunnel-ssl-conf $root 5532 localhost 8441 5432
-../../modules/http/tunnel-ssl-conf $root 5533 localhost 8441 5433
-../../modules/http/tunnel-ssl-conf $root 5534 localhost 8441 5433
+../../modules/http/httpd-ssl-conf $root $sslport/563