From d7e6bfc901c8a0aa1fcc9beb89b9fe33e388cbfa Mon Sep 17 00:00:00 2001 From: Ivor Wanders Date: Tue, 19 Apr 2022 13:16:59 -0400 Subject: [PATCH] Move postgres host and port to a single location. This makes it easier to use a different postgres instance when developing on hydra. The LOGNAME variable is new, but it is necessary for the queue runner to come up. --- flake.nix | 5 ++++- foreman/start-hydra.sh | 6 +++--- foreman/start-postgres.sh | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/flake.nix b/flake.nix index 2e8913641..3b65ec120 100644 --- a/flake.nix +++ b/flake.nix @@ -624,7 +624,10 @@ export HYDRA_HOME="$(pwd)/src/" mkdir -p .hydra-data export HYDRA_DATA="$(pwd)/.hydra-data" - export HYDRA_DBI='dbi:Pg:dbname=hydra;host=localhost;port=64444' + export LOGNAME="hydra-dev" + export PGPORT=64444 + export PGHOST="localhost" + export HYDRA_DBI="dbi:Pg:dbname=hydra;host=$PGHOST;port=$PGPORT" popd >/dev/null ''; diff --git a/foreman/start-hydra.sh b/foreman/start-hydra.sh index bb8cc9095..37bd1a7aa 100755 --- a/foreman/start-hydra.sh +++ b/foreman/start-hydra.sh @@ -1,15 +1,15 @@ #!/bin/sh # wait for postgresql to listen -while ! pg_isready -h $(pwd)/.hydra-data/postgres -p 64444; do sleep 1; done +while ! pg_isready ; do sleep 1; done -createdb -h $(pwd)/.hydra-data/postgres -p 64444 hydra +createdb hydra # create a db for the default user. Not sure why, but # the terminal is otherwise spammed with: # # FATAL: database "USERNAME" does not exist -createdb -h $(pwd)/.hydra-data/postgres -p 64444 "$(whoami)" || true +createdb "$(whoami)" || true hydra-init hydra-create-user alice --password foobar --role admin diff --git a/foreman/start-postgres.sh b/foreman/start-postgres.sh index c3fd7669e..630429ae2 100755 --- a/foreman/start-postgres.sh +++ b/foreman/start-postgres.sh @@ -1,4 +1,4 @@ #!/bin/sh initdb ./.hydra-data/postgres -exec postgres -D ./.hydra-data/postgres -k $(pwd)/.hydra-data/postgres -p 64444 +exec postgres -D ./.hydra-data/postgres -k $(pwd)/.hydra-data/postgres -p ${PGPORT}