Commit 04d588df authored by Micha Mueller's avatar Micha Mueller
Browse files

Fix premature exiting of dcdbpusher if all sensors were stopped over REST API

parent ba3a8bda
......@@ -49,6 +49,7 @@ using namespace std;
volatile int keepRunning;
pluginVector_t plugins;
boost::shared_ptr<boost::asio::io_service::work> keepAliveWork;
void sigintHandler(int sig) {
boost::log::sources::severity_logger<boost::log::trivial::severity_level> lg;
......@@ -61,9 +62,8 @@ void sigintHandler(int sig) {
LOG(info) << "Flushing MQTT queues...";
//Stop MQTTPusher
keepRunning = 0;
//Stop io service by killing keepAliveWork
void sigtermHandler(int sig) {
......@@ -317,6 +317,9 @@ int main(int argc, char** argv) {
LOG(info) << "Creating threads...";
//dummy to keep io service alive even if no tasks remain (e.g. because all sensors have been stopped over REST API)
keepAliveWork = boost::make_shared<boost::asio::io_service::work>(io);
//Create pool of threads which handle the sensors
for(size_t i = 0; i < globalSettings.threads; i++) {
threads.create_thread(bind(static_cast< size_t (boost::asio::io_service::*) () >(&boost::asio::io_service::run), &io));
......@@ -335,9 +338,15 @@ int main(int argc, char** argv) {
LOG(trace) << "Running...";
//Run until Strg+C
//will only continue if interrupted by SIGINT and threads were stopped
//Stop MQTTPusher
LOG(info) << "Flushing MQTT queues...";
keepRunning = 0;
//Stop https server
LOG(info) << "Stopping REST API Server...";
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment