forked from lix-project/hydra
Periodically close RemoteStore connections
This prevents an accumulation of temproots. See
89dc62c174
.
This commit is contained in:
parent
6517446c34
commit
b828224fee
|
@ -8,6 +8,7 @@
|
|||
#include "state.hh"
|
||||
#include "build-result.hh"
|
||||
#include "store-api.hh"
|
||||
#include "remote-store.hh"
|
||||
|
||||
#include "shared.hh"
|
||||
#include "globals.hh"
|
||||
|
@ -814,6 +815,7 @@ void State::run(BuildID buildOne)
|
|||
|
||||
Store::Params localParams;
|
||||
localParams["max-connections"] = "16";
|
||||
localParams["max-connection-age"] = "600";
|
||||
localStore = openStore(getEnv("NIX_REMOTE"), localParams);
|
||||
|
||||
auto storeUri = config->getStrOption("store_uri");
|
||||
|
@ -891,6 +893,20 @@ void State::run(BuildID buildOne)
|
|||
}
|
||||
}).detach();
|
||||
|
||||
/* Make sure that old daemon connections are closed even when
|
||||
we're not doing much. */
|
||||
std::thread([&]() {
|
||||
while (true) {
|
||||
sleep(10);
|
||||
try {
|
||||
if (auto remoteStore = getDestStore().dynamic_pointer_cast<RemoteStore>())
|
||||
remoteStore->flushBadConnections();
|
||||
} catch (std::exception & e) {
|
||||
printMsg(lvlError, format("connection flush thread: %1%") % e.what());
|
||||
}
|
||||
}
|
||||
}).detach();
|
||||
|
||||
/* Monitor the database for status dump requests (e.g. from
|
||||
‘hydra-queue-runner --status’). */
|
||||
while (true) {
|
||||
|
|
Loading…
Reference in a new issue