diff --git a/src/satellite.cpp b/src/satellite.cpp index 31f1894..6723eeb 100644 --- a/src/satellite.cpp +++ b/src/satellite.cpp @@ -443,6 +443,7 @@ int command_satellite (Config& config, const std::vector & args) bool debug = false; bool exit_on_idle = false; int builds_max = 0; + int timeout_max = 0; std::vector ::const_iterator i; for (i = ++(args.begin ()); i != args.end (); ++i) { @@ -450,12 +451,17 @@ int command_satellite (Config& config, const std::vector & args) else if (closeEnough ("--keep", *i, 3)) keep = true; else if (closeEnough ("--debug", *i, 3)) debug = true; else if (closeEnough ("--exit-on-idle", *i, 3)) exit_on_idle = true; - else if (counter (*i, builds_max)) ; + else if (closeEnough ("--max-jobs", *i, 3)) builds_max = strtol (i->substr(10).c_str (), NULL, 10); + else if (closeEnough ("--max-timeouts", *i, 3)) timeout_max = strtol (i->substr(10).c_str (), NULL, 10); else if (flod_applyOverride (config, *i)) ; else throw std::string ("ERROR: Unrecognized argument '") + *i + "'"; } + if (!builds_max && timeout_max) { + throw std::string ("ERROR: --max-timeouts is only to be used in conjunction with --max-jobs'"); + } + // Preserve the verbose and debug settings for this run. config.set ("verbose", verbose); config.set ("debug", debug); @@ -480,6 +486,9 @@ int command_satellite (Config& config, const std::vector & args) // Count the jobs, simply to allow easy differentiation in the log file. int job_count = 0; + // Count the timeouts (Central not responding) + int timeout_count = 0; + try { // Wait before beginning work. @@ -516,6 +525,8 @@ int command_satellite (Config& config, const std::vector & args) Msg response; if (flod_sendMessage (config, "central.server", work, response, false)) { + // Reset timeout count + timeout_count = 0; // Make a temporary copy of the configuration, which will be clobbered. Config work_config (config); work_config.set ("verbose", verbose ? 1 : 0); @@ -641,6 +652,10 @@ int command_satellite (Config& config, const std::vector & args) { log.write ("WARNING: Central unavailable"); + if (++timeout_count == timeout_max) { + log.write ("Automatic exit on timeout."); + } + // This delay throttles the work.Request rate when central is // unavailable. sleep (delay);