summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/components
diff options
context:
space:
mode:
Diffstat (limited to 'sca-cpp/trunk/components')
-rwxr-xr-xsca-cpp/trunk/components/cache/memcached-start4
-rw-r--r--sca-cpp/trunk/components/log/Makefile.am7
-rw-r--r--sca-cpp/trunk/components/log/scribe-status.cpp66
-rw-r--r--sca-cpp/trunk/components/log/scribe.hpp39
-rwxr-xr-xsca-cpp/trunk/components/sqldb/pgsql-conf2
-rwxr-xr-xsca-cpp/trunk/components/sqldb/pgsql-start2
6 files changed, 113 insertions, 7 deletions
diff --git a/sca-cpp/trunk/components/cache/memcached-start b/sca-cpp/trunk/components/cache/memcached-start
index 947b583ec0..692a066010 100755
--- a/sca-cpp/trunk/components/cache/memcached-start
+++ b/sca-cpp/trunk/components/cache/memcached-start
@@ -44,8 +44,8 @@ mkdir -p $root/memcached
echo $log > $root/memcached/logger
if [ "$ip" = "" ]; then
- ($memcached_prefix/bin/memcached -d -m 4 -p $port $v 2>&1 | sh $root/memcached/logger)&
+ nohup /bin/sh -c "($memcached_prefix/bin/memcached -d -m 4 -p $port $v 2>&1 | sh $root/memcached/logger)" 1>/dev/null 2>/dev/null &
else
- ($memcached_prefix/bin/memcached -d -l $ip -m 4 -p $port $v 2>&1 | sh $root/memcached/logger)&
+ nohup /bin/sh -c "($memcached_prefix/bin/memcached -d -l $ip -m 4 -p $port $v 2>&1 | sh $root/memcached/logger)" 1>/dev/null 2>/dev/null &
fi
diff --git a/sca-cpp/trunk/components/log/Makefile.am b/sca-cpp/trunk/components/log/Makefile.am
index 92be162101..5d685babec 100644
--- a/sca-cpp/trunk/components/log/Makefile.am
+++ b/sca-cpp/trunk/components/log/Makefile.am
@@ -57,13 +57,18 @@ liblogger_la_LDFLAGS = -L${THRIFT_LIB} -R${THRIFT_LIB} -lthrift -L${FB303_LIB} -
liblogger${libsuffix}:
ln -s .libs/liblogger${libsuffix}
-comp_PROGRAMS = scribe-cat
+comp_PROGRAMS = scribe-cat scribe-status
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 -Wno-conversion -Wno-return-type
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
+nodist_scribe_status_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_status_CXXFLAGS = -Wno-unused-parameter -Wno-conversion -Wno-return-type
+scribe_status_SOURCES = scribe-status.cpp
+scribe_status_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-status.cpp b/sca-cpp/trunk/components/log/scribe-status.cpp
new file mode 100644
index 0000000000..0e5f03f501
--- /dev/null
+++ b/sca-cpp/trunk/components/log/scribe-status.cpp
@@ -0,0 +1,66 @@
+/*
+ * 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 scribestatus {
+
+const int status(const string& host, const int port) {
+ // Connect to Scribe
+ scribe::Scribe& sc = *(new (gc_new<scribe::Scribe>()) scribe::Scribe(host, port));
+
+ // Get its status
+ const failable<string> fs = scribe::status(sc);
+
+ // Interpret and display results
+ if (!hasContent(fs)) {
+ cerr << reason(fs) << endl;
+ return 2;
+ }
+ const string s = content(fs);
+ cout << s << endl;
+ if (s == "ALIVE")
+ return 0;
+ if (s == "STARTING" || s == "STOPPING" || s == "WARNING")
+ return 1;
+ return 2;
+}
+
+}
+}
+
+int main(const int argc, const char** argv) {
+ return tuscany::scribestatus::status(argc < 2? "localhost" : argv[1], argc < 3? 1463 : atoi(argv[2]));
+}
+
diff --git a/sca-cpp/trunk/components/log/scribe.hpp b/sca-cpp/trunk/components/log/scribe.hpp
index a7fecf9865..7fa420f945 100644
--- a/sca-cpp/trunk/components/log/scribe.hpp
+++ b/sca-cpp/trunk/components/log/scribe.hpp
@@ -37,7 +37,7 @@
#undef OK
// Ignore integer conversion issues in Thrift and Scribe headers
-#ifdef WANT_MAINTAINER_MODE
+#ifdef WANT_MAINTAINER_WARNINGS
#pragma GCC diagnostic ignored "-Wconversion"
#endif
@@ -47,7 +47,7 @@
#include "gen-cpp/scribe.h"
-#ifdef WANT_MAINTAINER_MODE
+#ifdef WANT_MAINTAINER_WARNINGS
#pragma GCC diagnostic warning "-Wconversion"
#endif
@@ -99,6 +99,7 @@ private:
boost::shared_ptr<apache::thrift::transport::TTransport> transport;
friend const failable<bool> log(const value& val, const value& category, const Scribe& sc);
+ friend const failable<string> status(const Scribe& sc);
/**
* Initialize the Scribe connection.
@@ -147,6 +148,40 @@ const failable<bool> log(const value& val, const value& category, const Scribe&
return true;
}
+/**
+ * Return Scribe status.
+ */
+const failable<string> status(const Scribe& sc) {
+ debug("scribe::status");
+
+ try {
+ ::facebook::fb303::fb_status s = sc.client->getStatus();
+ switch(s) {
+ case ::facebook::fb303::DEAD:
+ debug("DEAD", "scribe::status::result");
+ return string("DEAD");
+ case ::facebook::fb303::STARTING:
+ debug("STARTING", "scribe::status::result");
+ return string("STARTING");
+ case ::facebook::fb303::ALIVE:
+ debug("ALIVE", "scribe::status::result");
+ return string("ALIVE");
+ case ::facebook::fb303::STOPPING:
+ debug("STOPPING", "scribe::status::result");
+ return string("STOPPING");
+ case ::facebook::fb303::STOPPED:
+ debug("STOPPED", "scribe::status::result");
+ return string("STOPPED");
+ case ::facebook::fb303::WARNING:
+ debug("WARNING", "scribe::status::result");
+ return string("WARNING");
+ }
+ return mkfailure<string>("Unknown status");
+ } catch (const std::exception& e) {
+ return mkfailure<string>(e.what());
+ }
+}
+
}
}
diff --git a/sca-cpp/trunk/components/sqldb/pgsql-conf b/sca-cpp/trunk/components/sqldb/pgsql-conf
index 2cfe47880b..21222a1183 100755
--- a/sca-cpp/trunk/components/sqldb/pgsql-conf
+++ b/sca-cpp/trunk/components/sqldb/pgsql-conf
@@ -98,7 +98,7 @@ host replication all samenet trust
EOF
# Create the db
-($pgsql_prefix/bin/pg_ctl start -W -D $root/sqldb/data 2>&1 | sh $root/sqldb/logger)&
+nohup /bin/sh -c "($pgsql_prefix/bin/pg_ctl start -W -D $root/sqldb/data 2>&1 | sh $root/sqldb/logger)" 1>/dev/null 2>/dev/null &
sti=0
while [ $sti -ne 30 ]; do
st=`$pgsql_prefix/bin/pg_ctl status -D $root/sqldb/data | grep 'server is running'`
diff --git a/sca-cpp/trunk/components/sqldb/pgsql-start b/sca-cpp/trunk/components/sqldb/pgsql-start
index 4a7e1ebe23..2955bec991 100755
--- a/sca-cpp/trunk/components/sqldb/pgsql-start
+++ b/sca-cpp/trunk/components/sqldb/pgsql-start
@@ -32,7 +32,7 @@ fi
mkdir -p $root/sqldb
echo $pgsql_log >$root/sqldb/logger
-($pgsql_prefix/bin/pg_ctl start -W -D $root/sqldb/data 2>&1 | sh $root/sqldb/logger)&
+nohup /bin/sh -c "($pgsql_prefix/bin/pg_ctl start -W -D $root/sqldb/data 2>&1 | sh $root/sqldb/logger)" 1>/dev/null 2>/dev/null &
sti=0
while [ $sti -ne 30 ]; do
st=`$pgsql_prefix/bin/pg_ctl status -D $root/sqldb/data | grep 'server is running'`