From ec8e8edc86799af88033fe5ed1d799c183e8168a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 17 Jun 2015 22:11:01 +0200 Subject: [PATCH] hydra-queue-runner: Handle $HYDRA_DBI --- src/hydra-queue-runner/hydra-queue-runner.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/hydra-queue-runner/hydra-queue-runner.cc b/src/hydra-queue-runner/hydra-queue-runner.cc index 56feaa54..2abded44 100644 --- a/src/hydra-queue-runner/hydra-queue-runner.cc +++ b/src/hydra-queue-runner/hydra-queue-runner.cc @@ -60,7 +60,16 @@ typedef enum { struct Connection : pqxx::connection { - Connection() : pqxx::connection("dbname=hydra") { }; + Connection() : pqxx::connection(getFlags()) { }; + + string getFlags() + { + string s = getEnv("HYDRA_DBI", "dbi:Pg:dbname=hydra;"); + string prefix = "dbi:Pg:"; + if (string(s, 0, prefix.size()) != prefix) + throw Error("$HYDRA_DBI does not denote a PostgreSQL database"); + return concatStringsSep(" ", tokenizeString(string(s, prefix.size()), ";")); + } };