Otherwise, you'd have to restart the queue runner to add or remove machines.
SODOV2CMWA4JMIKRQNJ6MD3U3BS2XTSLINLRAG4SFY742IIJNI5QC FKLICOHYATLMF3Q6YBQAOVKBRTCDY2TLKHML3B4DUI7YX4H4MQCAC ODCBSLFGJGNOMKPZV6TS2SVTQMVUXR3K2BQJHNAJHTR4HECDBBNAC O64P4XJSK56UN73VA5JUAM4RHFDWOZJDDYKVOKMUB736ODOAUYNAC IE2PRAQUCQVFPJ4CAIJRPXXEFC5VBAE3EO5I5FG4XWEDRNONNHKQC MB3TISH2KYBIGY6XJKMN4HO2S6TCN2GORJENMECCKLXGGIRS2O2AC 5AIYUMTBY6TFQTBRP3MJ2PYWUMRF57I77NIVWYE74UMEVQMBWZVQC 24BMQDZAWDQ7VNIA7TIROXSOYLOJBNZ2E4264WHWNJAEN6ZB3UOAC N5O7VEEOY2IE27VCOYRBG7YCY3K7JMQEDEMRT4OQ2MUE3NWULHHQC ENXUSMSVOU3AZFMH2ZXR4ZVPV2LRRQYQJ6IFX33YN6IH2ORSNSAAC NNOCZ4ROWC64ZKSAE2MPHZ3LGLI34C5TJJFW4MHXN6OELK6VMWOQC GS4BE6TB6GH2JUZJHDPHL6YG7J7YYESF3YOZJZ2CFABXUTO4VYPQC HLSHCK3CP4RB6VO6N44FBHWMXBJYB6XPNWM5EKCKWU3KISU37N3AC OCZ4LSGGSCMSLGC3C32D5JUYYHS5CIPOKOAMADEFAFZOFXJ3YY3AC 63W4T5PUSRHU53CVVTVRWAQX6T74RIHH636NCGUGPN3YFVMC3VTAC PLOZBRTR6USSGJX7GR2RZKNPVYG2Q6QM7LW6IA35MKL63ZTQVD7QC NJJ7H64SZOX5EGACDCQAUQ7R6UEWD5IIC35A2MWFOOJV55DJYPHAC counter currentJobs{0};counter nrStepsDone{0};counter totalStepTime{0}; // total time for steps, including closure copyingcounter totalStepBuildTime{0}; // total build time for steps
struct State {typedef std::shared_ptr<State> ptr;counter currentJobs{0};counter nrStepsDone{0};counter totalStepTime{0}; // total time for steps, including closure copyingcounter totalStepBuildTime{0}; // total build time for steps};State::ptr state;
}};/* A RAII helper that manages the currentJobs field of Machineobjects. */struct MachineReservation{typedef std::shared_ptr<MachineReservation> ptr;Machine::ptr machine;MachineReservation(Machine::ptr machine) : machine(machine){machine->currentJobs++;}~MachineReservation(){machine->currentJobs--;
struct stat st;if (stat(machinesFile.c_str(), &st) != 0)throw SysError(format("getting stats about ‘%1%’") % machinesFile);if (st.st_ino == machinesFileStat.st_ino && st.st_mtime == machinesFileStat.st_mtime)return;printMsg(lvlDebug, "reloading machines");contents = readFile(machinesFile);machinesFileStat = st;} else {StringSet systems = StringSet({settings.thisSystem});if (settings.thisSystem == "x86_64-linux")systems.insert("i686-linux");contents = "localhost " + concatStringsSep(",", systems)+ " - " + int2String(settings.maxBuildJobs) + " 1";}
for (auto line : tokenizeString<Strings>(readFile(machinesFile), "\n")) {line = trim(string(line, 0, line.find('#')));auto tokens = tokenizeString<std::vector<std::string>>(line);if (tokens.size() < 3) continue;tokens.resize(7);
Machines newMachines, oldMachines;{auto machines_(machines.lock());oldMachines = *machines_;}
auto machine = std::make_shared<Machine>();machine->sshName = tokens[0];machine->systemTypes = tokenizeString<StringSet>(tokens[1], ",");machine->sshKey = tokens[2];if (tokens[3] != "")string2Int(tokens[3], machine->maxJobs);elsemachine->maxJobs = 1;machine->speedFactor = atof(tokens[4].c_str());machine->supportedFeatures = tokenizeString<StringSet>(tokens[5], ",");machine->mandatoryFeatures = tokenizeString<StringSet>(tokens[6], ",");for (auto & f : machine->mandatoryFeatures)machine->supportedFeatures.insert(f);newMachines.push_back(machine);}
for (auto line : tokenizeString<Strings>(contents, "\n")) {line = trim(string(line, 0, line.find('#')));auto tokens = tokenizeString<std::vector<std::string>>(line);if (tokens.size() < 3) continue;tokens.resize(7);
machine->sshName = "localhost";machine->systemTypes = StringSet({settings.thisSystem});if (settings.thisSystem == "x86_64-linux")machine->systemTypes.insert("i686-linux");machine->maxJobs = settings.maxBuildJobs;newMachines.push_back(machine);
machine->sshName = tokens[0];machine->systemTypes = tokenizeString<StringSet>(tokens[1], ",");machine->sshKey = tokens[2];if (tokens[3] != "")string2Int(tokens[3], machine->maxJobs);elsemachine->maxJobs = 1;machine->speedFactor = atof(tokens[4].c_str());machine->supportedFeatures = tokenizeString<StringSet>(tokens[5], ",");machine->mandatoryFeatures = tokenizeString<StringSet>(tokens[6], ",");for (auto & f : machine->mandatoryFeatures)machine->supportedFeatures.insert(f);/* Re-use the State object of the previous machine with thesame name. */auto i = oldMachines.find(machine->sshName);if (i == oldMachines.end())printMsg(lvlChatty, format("adding new machine ‘%1%’") % machine->sshName);elseprintMsg(lvlChatty, format("updating machine ‘%1%’") % machine->sshName);machine->state = i == oldMachines.end()? std::make_shared<Machine::State>(): i->second->state;newMachines[machine->sshName] = machine;
machine->nrStepsDone++;machine->totalStepTime += stepStopTime - stepStartTime;machine->totalStepBuildTime += result.stopTime - result.startTime;
machine->state->nrStepsDone++;machine->state->totalStepTime += stepStopTime - stepStartTime;machine->state->totalStepBuildTime += result.stopTime - result.startTime;
nested2.attr("currentJobs", m->currentJobs);nested2.attr("nrStepsDone", m->nrStepsDone);if (m->nrStepsDone) {nested2.attr("totalStepTime", m->totalStepTime);nested2.attr("totalStepBuildTime", m->totalStepBuildTime);nested2.attr("avgStepTime"); out << (float) m->totalStepTime / m->nrStepsDone;nested2.attr("avgStepBuildTime"); out << (float) m->totalStepBuildTime / m->nrStepsDone;
nested2.attr("currentJobs", s->currentJobs);nested2.attr("nrStepsDone", s->nrStepsDone);if (m->state->nrStepsDone) {nested2.attr("totalStepTime", s->totalStepTime);nested2.attr("totalStepBuildTime", s->totalStepBuildTime);nested2.attr("avgStepTime"); out << (float) s->totalStepTime / s->nrStepsDone;nested2.attr("avgStepBuildTime"); out << (float) s->totalStepBuildTime / s->nrStepsDone;