Commit 2cf6acc5 authored by Alessio Netti's avatar Alessio Netti

Minor changes

- Fixed a minor issue that caused text corruption when using the -h
option on certain shells
- Collectagent now exits gracefully also when receiving a SIGTERM signal
parent ea5162ee
......@@ -68,6 +68,11 @@ DCDBLog::logger_t lg;
/* Normal termination (SIGINT, CTRL+C) */
void sigHandler(int sig)
{
boost::log::sources::severity_logger<boost::log::trivial::severity_level> lg;
if( sig == SIGINT )
LOG(fatal) << "Received SIGINT";
else if( sig == SIGTERM )
LOG(fatal) << "Received SIGTERM";
keepRunning = 0;
}
......@@ -232,7 +237,8 @@ int mqttCallback(SimpleMQTTMessage *msg)
* Print usage information
*/
void usage() {
globalCA_t& defaults = Configuration("").getGlobal();
Configuration config("");
globalCA_t& defaults = config.getGlobal();
/*
1 2 3 4 5 6 7 8
012345678901234567890123456789012345678901234567890123456789012345678901234567890
......@@ -358,16 +364,16 @@ int main(int argc, char* const argv[]) {
cmdSink->set_filter(boost::log::trivial::severity >= settings.logLevelCmd);
/*
* Catch SIGINT signals to allow for proper server shutdowns.
* Catch SIGINT and SIGTERM signals to allow for proper server shutdowns.
*/
signal(SIGINT, sigHandler);
signal(SIGTERM, sigHandler);
/*
* Catch critical signals to allow for backtraces
*/
signal(SIGABRT, abrtHandler);
signal(SIGSEGV, abrtHandler);
signal(SIGTERM, abrtHandler);
// Daemonizing the collectagent
if(settings.daemonize)
......@@ -491,7 +497,7 @@ int main(int argc, char* const argv[]) {
elapsed = (end.tv_sec - start.tv_sec) * 1000.0;
elapsed += (end.tv_usec - start.tv_usec) / 1000.0;
float publish = msgCtr?(pmsgCtr*100.0)/msgCtr:0;
if (settings.statistics) {
if (settings.statistics && keepRunning) {
LOG(info) << "Performance: " << (readingCtr/elapsed)*1000.0 << " inserts/s, " << (msgCtr/elapsed)*1000.0 << " messages/s (" << publish << "% PUBLISH)";
}
msgCtr = 0;
......
Markdown is supported
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