339
339
"ARG_POSITIONAL_SINGLE([command], [Command to run])"
340
340
"ARG_LEFTOVERS([command arguments])"
341
341
"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])"
342
343
] ;
343
344
positionalCompletion = "_command" ;
344
345
workingDir = "/" ;
@@ -348,20 +349,22 @@ let
348
349
''
349
350
export PGRST_SERVER_UNIX_SOCKET="$tmpdir"/postgrest.socket
350
351
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
365
368
fi
366
369
echo "done."
367
370
373
376
pid=$!
374
377
# shellcheck disable=SC2317
375
378
cleanup() {
379
+ kill -HUP "$pid" #
376
380
kill "$pid" || true
377
381
}
378
382
trap cleanup EXIT
0 commit comments