Skip to content
Snippets Groups Projects
Commit 8e33cbc3 authored by Dinyar Rabady's avatar Dinyar Rabady Committed by Dinyar Rabady
Browse files

Quit more gracefully if configuration incomplete

Belongs to #15.
parent 712b63fa
No related branches found
No related tags found
No related merge requests found
...@@ -59,7 +59,7 @@ enable_stream_processor:yes ...@@ -59,7 +59,7 @@ enable_stream_processor:yes
# Note: When changing the processing type, change also "output_filename_prefix" # Note: When changing the processing type, change also "output_filename_prefix"
# in the file output section. # in the file output section.
# #
#processor_type:GMT processor_type:
# Enable software zero-supression # Enable software zero-supression
doZS:yes doZS:yes
...@@ -70,9 +70,9 @@ doZS:yes ...@@ -70,9 +70,9 @@ doZS:yes
## ##
################################################################################ ################################################################################
#output_filename_prefix:scout_GMT output_filename_prefix:
#output_filename_base:/fff/BU0/ramdisk/scdaq output_filename_base:
max_file_size:8589934592 max_file_size:8589934592
......
...@@ -15,6 +15,10 @@ while true ...@@ -15,6 +15,10 @@ while true
do do
echo "Starting scdaq..." echo "Starting scdaq..."
/opt/scdaq/bin/scdaq --config /etc/scdaq/scdaq.conf 2>&1 /opt/scdaq/bin/scdaq --config /etc/scdaq/scdaq.conf 2>&1
if [[ ${PIPESTATUS[0]} == 78 ]]; then # Numerical value of EX_CONFIG.
# If the configuration is incomplete there's no point in us retrying forever..
exit 1
fi
echo "Resetting the board..." echo "Resetting the board..."
../scripts/reset-firmware.sh ../scripts/reset-firmware.sh
echo "Clearing caches..." echo "Clearing caches..."
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#include "log.h" #include "log.h"
config::config(std::string filename) { config::config(std::string filename) {
bool valid = true;
std::ifstream in(filename.c_str(), std::ios_base::in); std::ifstream in(filename.c_str(), std::ios_base::in);
std::string line; std::string line;
while (!std::getline(in, line).eof()) { while (!std::getline(in, line).eof()) {
...@@ -31,15 +33,22 @@ config::config(std::string filename) { ...@@ -31,15 +33,22 @@ config::config(std::string filename) {
std::string key = line.substr(0, delim); std::string key = line.substr(0, delim);
std::string value = line.substr(delim + 1); std::string value = line.substr(delim + 1);
if (key.empty() || value.empty()) { if (key.empty()) {
// Skip ill formated lines // Skip ill formated lines
continue; continue;
} }
// std::cout << "key: " << key << ", value: " << value << "\n"; if (value.empty()) {
LOG(ERROR) << "Configuration entry " << key << " has no value!";
valid &= false;
}
vmap[key] = value; vmap[key] = value;
} }
if (!valid) {
throw std::invalid_argument("Configuration error: Keys with no value detected!");
}
} }
void config::print() const { void config::print() const {
for (std::map<std::string, std::string>::const_iterator it = vmap.begin(); it != vmap.end(); for (std::map<std::string, std::string>::const_iterator it = vmap.begin(); it != vmap.end();
......
#include <sysexits.h>
#include <boost/asio.hpp> #include <boost/asio.hpp>
#include <boost/bind.hpp> #include <boost/bind.hpp>
#include <boost/thread.hpp> #include <boost/thread.hpp>
...@@ -197,7 +199,9 @@ int main(int argc, char *argv[]) { ...@@ -197,7 +199,9 @@ int main(int argc, char *argv[]) {
// utility::report_elapsed_time((tbb::tick_count::now() - // utility::report_elapsed_time((tbb::tick_count::now() -
// mainStartTime).seconds()); // mainStartTime).seconds());
return retval; return retval;
} catch (std::exception &e) {
LOG(FATAL) << "Configuration invalid! Error text is \"" << e.what() << "\" Bailing out.";
return EX_CONFIG;
} catch (std::exception &e) { } catch (std::exception &e) {
LOG(ERROR) << "Error occurred. error text is: \"" << e.what() << "\""; LOG(ERROR) << "Error occurred. error text is: \"" << e.what() << "\"";
return 1; return 1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment