[dss-commits] digitalSTROM Server branch, master, updated. 0950b82b085b14e944d6c426d2bd1a4b2edfc751
git version control
dss-commits at forum.digitalstrom.org
Mon Dec 14 10:56:04 CET 2009
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "digitalSTROM Server".
The branch, master has been updated
via 0950b82b085b14e944d6c426d2bd1a4b2edfc751 (commit)
via ac1af7d60e26528ef3a1ac7737b8ac91a24952f2 (commit)
via adc0c4cfe8a10e64789180b5c10283f1210613b1 (commit)
from c7000db55ee2a8a84d66a0aa9e0c1fa6e163bdb5 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 0950b82b085b14e944d6c426d2bd1a4b2edfc751
Merge: c7000db55ee2a8a84d66a0aa9e0c1fa6e163bdb5 ac1af7d60e26528ef3a1ac7737b8ac91a24952f2
Author: Johannes Winkelmann <johannes.winkelmann at aizo.com>
Date: Mon Dec 14 10:43:33 2009 +0100
Merge branch 'split-datadir'
commit ac1af7d60e26528ef3a1ac7737b8ac91a24952f2
Author: Johannes Winkelmann <johannes.winkelmann at aizo.com>
Date: Fri Dec 11 14:43:50 2009 +0100
introduce "Config directory" and "Webroot Directory"
To distinguish between different kinds of config/data files, this commit
introduces two new settings, the "config directory" and the "webroot
directory". The split is meant to be implemented like this:
- files written by the dss should go into the 'data' directory
- files written by the users should go into the 'config' directory
- web server files should go into 'webroot' directory
WITH_CONFIG and WITH_WEBROOTDIR default to $WITH_DATADIR{,/webroot}
commit adc0c4cfe8a10e64789180b5c10283f1210613b1
Author: Johannes Winkelmann <johannes.winkelmann at aizo.com>
Date: Thu Dec 10 09:58:03 2009 +0100
add dss supervisor script
-----------------------------------------------------------------------
Changes:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d87bdbb..7050537 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,6 +9,14 @@ IF(NOT WITH_DATADIR)
SET(WITH_DATADIR "${CMAKE_INSTALL_PREFIX}/share/dss/data" CACHE FILEPATH "Data directory")
ENDIF(NOT WITH_DATADIR)
+IF(NOT WITH_CONFIGDIR)
+ SET(WITH_CONFIGDIR "${WITH_DATADIR}" CACHE FILEPATH "Config directory")
+ENDIF(NOT WITH_CONFIGDIR)
+
+IF(NOT WITH_WEBROOTDIR)
+ SET(WITH_WEBROOTDIR "${WITH_DATADIR}/webroot" CACHE FILEPATH "Webroot directory")
+ENDIF(NOT WITH_WEBROOTDIR)
+
SET(DSS_GEN_VERSION_CMD "")
IF(WIN32)
SET(DSS_GEN_VERSION_CMD "tools/dss_gen_version_win32.bat")
diff --git a/config.h.in b/config.h.in
index bb470ea..57e64dc 100644
--- a/config.h.in
+++ b/config.h.in
@@ -14,6 +14,8 @@
#cmakedefine WITH_SIM
#cmakedefine WITH_TESTS
#cmakedefine WITH_DATADIR "${WITH_DATADIR}"
+#cmakedefine WITH_CONFIGDIR "${WITH_CONFIGDIR}"
+#cmakedefine WITH_WEBROOTDIR "${WITH_WEBROOTDIR}"
#cmakedefine WITH_BONJOUR
#cmakedefine WITH_GCOV
diff --git a/core/dss.cpp b/core/dss.cpp
index 7f691c0..423180e 100644
--- a/core/dss.cpp
+++ b/core/dss.cpp
@@ -71,17 +71,35 @@ const char* DataDirectory = WITH_DATADIR;
const char* DataDirectory = "data/";
#endif
+#ifdef WITH_CONFIGDIR
+const char* ConfigDirectory = WITH_CONFIGDIR;
+#else
+const char* ConfigDirectory = "data/";
+#endif
+
+#ifdef WITH_WEBROOTDIR
+const char* WebrootDirectory = WITH_WEBROOTDIR;
+#else
+const char* WebrootDirectory = "data/webroot";
+#endif
+
DSS::DSS()
{
m_State = ssInvalid;
m_pPropertySystem = boost::shared_ptr<PropertySystem>(new PropertySystem);
setDataDirectory(DataDirectory);
+ setConfigDirectory(ConfigDirectory);
+ setWebrootDirectory(WebrootDirectory);
m_TimeStarted = time(NULL);
m_pPropertySystem->createProperty("/system/uptime")->linkToProxy(
PropertyProxyMemberFunction<DSS,int>(*this, &DSS::getUptime));
m_pPropertySystem->createProperty("/config/datadirectory")->linkToProxy(
PropertyProxyMemberFunction<DSS,string>(*this, &DSS::getDataDirectory, &DSS::setDataDirectory));
+ m_pPropertySystem->createProperty("/config/configdirectory")->linkToProxy(
+ PropertyProxyMemberFunction<DSS,string>(*this, &DSS::getConfigDirectory, &DSS::setConfigDirectory));
+ m_pPropertySystem->createProperty("/config/webrootdirectory")->linkToProxy(
+ PropertyProxyMemberFunction<DSS,string>(*this, &DSS::getWebrootDirectory, &DSS::setWebrootDirectory));
} // ctor
DSS::~DSS() {
@@ -113,12 +131,28 @@ const char* DataDirectory = "data/";
void DSS::setDataDirectory(const string& _value) {
if(!_value.empty() && (_value.at(_value.length() - 1) != '/')) {
- m_DataDirectory = _value + "/";
+ m_dataDirectory = _value + "/";
} else {
- m_DataDirectory = _value;
+ m_dataDirectory = _value;
}
} // setDataDirectory
+ void DSS::setConfigDirectory(const string& _value) {
+ if(!_value.empty() && (_value.at(_value.length() - 1) != '/')) {
+ m_configDirectory = _value + "/";
+ } else {
+ m_configDirectory = _value;
+ }
+ }
+
+ void DSS::setWebrootDirectory(const string& _value) {
+ if(!_value.empty() && (_value.at(_value.length() - 1) != '/')) {
+ m_webrootDirectory = _value + "/";
+ } else {
+ m_webrootDirectory = _value;
+ }
+ }
+
bool DSS::initialize(const vector<string>& _properties) {
m_State = ssCreatingSubsystems;
@@ -259,7 +293,10 @@ const char* DataDirectory = "data/";
void DSS::run() {
Logger::getInstance()->log("DSS starting up....", lsInfo);
Logger::getInstance()->log(versionString(), lsInfo);
- Logger::getInstance()->log("Using data directory '" + getDataDirectory() + "'", lsInfo);
+ Logger::getInstance()->log("Configuration: ", lsInfo);
+ Logger::getInstance()->log(" data: '" + getDataDirectory() + "'", lsInfo);
+ Logger::getInstance()->log(" config: '" + getConfigDirectory() + "'", lsInfo);
+ Logger::getInstance()->log(" webroot '" + getWebrootDirectory() + "'", lsInfo);
SystemInfo info;
info.collect();
@@ -292,7 +329,7 @@ const char* DataDirectory = "data/";
bool DSS::loadConfig() {
m_State = ssLoadingConfig;
Logger::getInstance()->log("Loading config", lsInfo);
- return getPropertySystem().loadFromXML(getDataDirectory() + "config.xml", getPropertySystem().getProperty("/config"));
+ return getPropertySystem().loadFromXML(getConfigDirectory() + "config.xml", getPropertySystem().getProperty("/config"));
} // loadConfig
diff --git a/core/dss.h b/core/dss.h
index ca91e24..298a8a4 100644
--- a/core/dss.h
+++ b/core/dss.h
@@ -80,7 +80,9 @@ namespace dss {
boost::shared_ptr<EventQueue> m_pEventQueue;
boost::shared_ptr<Metering> m_pMetering;
boost::shared_ptr<FakeMeter> m_pFakeMeter;
- std::string m_DataDirectory;
+ std::string m_dataDirectory;
+ std::string m_configDirectory;
+ std::string m_webrootDirectory;
aDSSState m_State;
@@ -123,8 +125,12 @@ namespace dss {
WebServer& getWebServer() { return *m_pWebServer; }
EventInterpreter& getEventInterpreter() { return *m_pEventInterpreter; }
- const std::string& getDataDirectory() const { return m_DataDirectory; }
+ const std::string& getDataDirectory() const { return m_dataDirectory; }
+ const std::string& getConfigDirectory() const { return m_configDirectory; }
+ const std::string& getWebrootDirectory() const { return m_webrootDirectory; }
void setDataDirectory(const std::string& _value);
+ void setConfigDirectory(const std::string& _value);
+ void setWebrootDirectory(const std::string& _value);
}; // DSS
}
diff --git a/core/event.cpp b/core/event.cpp
index 79e48e0..d783cdb 100644
--- a/core/event.cpp
+++ b/core/event.cpp
@@ -184,7 +184,7 @@ namespace dss {
void EventInterpreter::initialize() {
Subsystem::initialize();
if(DSS::hasInstance()) {
- getDSS().getPropertySystem().setStringValue(getConfigPropertyBasePath() + "subscriptionfile", getDSS().getDataDirectory() + "subscriptions.xml", true, false);
+ getDSS().getPropertySystem().setStringValue(getConfigPropertyBasePath() + "subscriptionfile", getDSS().getConfigDirectory() + "subscriptions.xml", true, false);
}
} // initialize
diff --git a/core/metering/fake_meter.cpp b/core/metering/fake_meter.cpp
index ddcf1e2..08d61b9 100644
--- a/core/metering/fake_meter.cpp
+++ b/core/metering/fake_meter.cpp
@@ -118,7 +118,7 @@ namespace dss {
Subsystem::initialize();
getDSS().getPropertySystem().setStringValue(getConfigPropertyBasePath() + "device", "/dev/ttyS2", true, false);
- getDSS().getPropertySystem().setStringValue(getConfigPropertyBasePath() + "storageLocation", getDSS().getDataDirectory()+"webroot/metering/", true, false);
+ getDSS().getPropertySystem().setStringValue(getConfigPropertyBasePath() + "storageLocation", getDSS().getWebrootDirectory()+"metering/", true, false);
getDSS().getPropertySystem().setBoolValue(getConfigPropertyBasePath() + "addJitter", false, true, false);
}
diff --git a/core/metering/metering.cpp b/core/metering/metering.cpp
index 8da52bd..7984070 100644
--- a/core/metering/metering.cpp
+++ b/core/metering/metering.cpp
@@ -38,7 +38,7 @@ namespace dss {
: Subsystem(_pDSS, "Metering"),
Thread("Metering")
{
- getDSS().getPropertySystem().setStringValue(getConfigPropertyBasePath() + "storageLocation", getDSS().getDataDirectory() + "webroot/metering/", true);
+ getDSS().getPropertySystem().setStringValue(getConfigPropertyBasePath() + "storageLocation", getDSS().getWebrootDirectory() + "metering/", true);
boost::shared_ptr<MeteringConfigChain> configConsumption(new MeteringConfigChain(false, 1, "mW"));
configConsumption->setComment("Consumption in mW");
configConsumption->addConfig(boost::shared_ptr<MeteringConfig>(new MeteringConfig("consumption_seconds", 2, 400)));
diff --git a/core/sim/dssim.cpp b/core/sim/dssim.cpp
index b5bc58b..6b62e8b 100644
--- a/core/sim/dssim.cpp
+++ b/core/sim/dssim.cpp
@@ -111,7 +111,7 @@ namespace dss {
}
}
- getDSS().getPropertySystem().setStringValue(getConfigPropertyBasePath() + "configfile", getDSS().getDataDirectory() + "sim.xml", true, false);
+ getDSS().getPropertySystem().setStringValue(getConfigPropertyBasePath() + "configfile", getDSS().getConfigDirectory() + "sim.xml", true, false);
loadPlugins();
loadFromConfig();
diff --git a/core/webserver.cpp b/core/webserver.cpp
index df66eb4..1ace0bf 100644
--- a/core/webserver.cpp
+++ b/core/webserver.cpp
@@ -63,7 +63,7 @@ namespace dss {
log("Starting Webserver...");
m_mgContext = mg_start();
- getDSS().getPropertySystem().setStringValue(getConfigPropertyBasePath() + "webroot", getDSS().getDataDirectory() + "webroot/", true, false);
+ getDSS().getPropertySystem().setStringValue(getConfigPropertyBasePath() + "webroot", getDSS().getWebrootDirectory(), true, false);
getDSS().getPropertySystem().setStringValue(getConfigPropertyBasePath() + "ports", "8080", true, false);
setupAPI();
diff --git a/tools/dss_supervisor b/tools/dss_supervisor
new file mode 100755
index 0000000..2fd34ad
--- /dev/null
+++ b/tools/dss_supervisor
@@ -0,0 +1,89 @@
+#!/bin/sh
+#
+# dss supervision script
+# Johannes Winkelmann, johannes.winkelmann at aizo.com
+
+# -- configuration
+SLEEP_TIME_SECONDS=300 # 5*60
+RESTART_COMMAND="/etc/init.d/dss restart"
+RESTART_LOG= #/tmp/dss_supervisor.log
+
+VERBOSE=0
+
+
+# -- helper functions
+log() {
+ echo "$(TZ=UTC date): $*" >> $RESTART_LOG
+}
+
+restart_dss() {
+ reason=$1
+ if [ -n "$RESTART_LOG" ]; then
+ log "Restarting dss; reason: $reason"
+ fi
+ $RESTART_COMMAND
+}
+
+print_info() {
+ [ $VERBOSE -eq 1 ] && echo $1
+}
+
+
+# -- check functions
+
+# check functions must return a non zero value if they detected an
+# error condition and took some action
+
+check_socket() {
+ # make sure that we have a socket on port $1 in LISTEN state; be
+ # aware that this check is rather naive in that it doesn't look
+ # at the process name, so it might be in fact another process
+ # listening on this port
+
+ port=$1
+ name=$2
+
+ count=$(netstat -an 2>/dev/null|grep ":$port"|grep -c LISTEN)
+ if [ $count -eq 0 ]; then
+ print_info "$name listener (port $port) unavailable; restarting dss"
+ restart_dss "$name listener (port $port) unavailable"
+ return 1
+ fi
+
+ return 0
+}
+
+check_soap() {
+ check_socket 8081 "SOAP"
+ return $?
+}
+
+check_http() {
+ check_socket 8080 "HTTP"
+ return $?
+}
+
+
+## -- main loop
+
+for arg in $*; do
+ case "$arg" in
+ "-v"|"--verbose")
+ VERBOSE=1
+ ;;
+ esac
+done
+
+CHECKS="soap http" # register additional checks here
+while true; do
+ for check in $CHECKS; do
+ print_info "Running $check check"
+ check_$check
+ if [ $? -ne 0 ]; then
+ # error condition: go to sleep before running the next test
+ break
+ fi
+ done
+
+ sleep $SLEEP_TIME_SECONDS
+done
\ No newline at end of file
hooks/post-receive
--
digitalSTROM Server
More information about the dss-commits
mailing list