Allow setting GC_INITIAL_HEAP_SIZE for hydra-eval-jobs
This cannot be done in the hydra-evaluator systemd unit, since then every other Nix process (e.g. hydra-evaluator and nix-prefetch-*) will also allocate the specified heap size, probably leading to OOM.
This commit is contained in:
52
src/libhydra/hydra-config.hh
Normal file
52
src/libhydra/hydra-config.hh
Normal file
@ -0,0 +1,52 @@
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "util.hh"
|
||||
|
||||
struct Config
|
||||
{
|
||||
std::map<std::string, std::string> options;
|
||||
|
||||
Config()
|
||||
{
|
||||
using namespace nix;
|
||||
|
||||
/* Read hydra.conf. */
|
||||
auto hydraConfigFile = getEnv("HYDRA_CONFIG");
|
||||
if (pathExists(hydraConfigFile)) {
|
||||
|
||||
for (auto line : tokenizeString<Strings>(readFile(hydraConfigFile), "\n")) {
|
||||
line = trim(string(line, 0, line.find('#')));
|
||||
|
||||
auto eq = line.find('=');
|
||||
if (eq == std::string::npos) continue;
|
||||
|
||||
auto key = trim(std::string(line, 0, eq));
|
||||
auto value = trim(std::string(line, eq + 1));
|
||||
|
||||
if (key == "") continue;
|
||||
|
||||
options[key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string getStrOption(const std::string & key, const std::string & def = "")
|
||||
{
|
||||
auto i = options.find(key);
|
||||
return i == options.end() ? def : i->second;
|
||||
}
|
||||
|
||||
uint64_t getIntOption(const std::string & key, uint64_t def = 0)
|
||||
{
|
||||
auto i = options.find(key);
|
||||
return i == options.end() ? def : std::stoll(i->second);
|
||||
}
|
||||
|
||||
bool getBoolOption(const std::string & key, bool def = false)
|
||||
{
|
||||
auto i = options.find(key);
|
||||
return i == options.end() ? def : (i->second == "true" || i->second == "1");
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user