Skip to content

Commit aba9623

Browse files
committed
add: override PGRST_CMD for postgrest-loadtest from env
Enables `PGRST_CMD=postgrest-profiled-run postgrest-loadtest` running loadtest against profiled executable, which wasn't available before
1 parent 5e0da40 commit aba9623

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

nix/tools/withTools.nix

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ let
339339
"ARG_POSITIONAL_SINGLE([command], [Command to run])"
340340
"ARG_LEFTOVERS([command arguments])"
341341
"ARG_OPTIONAL_SINGLE([monitor], [m], [Enable CPU and memory monitoring of the PostgREST process and output to the designated file as markdown])"
342+
"ARG_USE_ENV([PGRST_CMD], [postgrest-run], [PostgREST executable to run])"
342343
];
343344
positionalCompletion = "_command";
344345
workingDir = "/";
@@ -348,20 +349,22 @@ let
348349
''
349350
export PGRST_SERVER_UNIX_SOCKET="$tmpdir"/postgrest.socket
350351
351-
rm -f result
352-
if [ -z "''${PGRST_BUILD_CABAL:-}" ]; then
353-
echo -n "Building postgrest (nix)... "
354-
# Using lib.getBin to also make this work with older checkouts, where .bin was not a thing, yet.
355-
nix-build -E 'with import ./. {}; pkgs.lib.getBin postgrestPackage' > "$tmpdir"/build.log 2>&1 || {
356-
echo "failed, output:"
357-
cat "$tmpdir"/build.log
358-
exit 1
359-
}
360-
PGRST_CMD=$(echo ./result*/bin/postgrest)
361-
else
362-
echo -n "Building postgrest (cabal)... "
363-
postgrest-build
364-
PGRST_CMD=postgrest-run
352+
if [ -z "''${PGRST_CMD:-}" ]; then
353+
rm -f result
354+
if [ -z "''${PGRST_BUILD_CABAL:-}" ]; then
355+
echo -n "Building postgrest (nix)... "
356+
# Using lib.getBin to also make this work with older checkouts, where .bin was not a thing, yet.
357+
nix-build -E 'with import ./. {}; pkgs.lib.getBin postgrestPackage' > "$tmpdir"/build.log 2>&1 || {
358+
echo "failed, output:"
359+
cat "$tmpdir"/build.log
360+
exit 1
361+
}
362+
PGRST_CMD=$(echo ./result*/bin/postgrest)
363+
else
364+
echo -n "Building postgrest (cabal)... "
365+
postgrest-build
366+
PGRST_CMD=postgrest-run
367+
fi
365368
fi
366369
echo "done."
367370
@@ -373,6 +376,7 @@ let
373376
pid=$!
374377
# shellcheck disable=SC2317
375378
cleanup() {
379+
kill -HUP "$pid" #
376380
kill "$pid" || true
377381
}
378382
trap cleanup EXIT

0 commit comments

Comments
 (0)