chore(develop): prevent multiple develop
This commit is contained in:
parent
09121883bf
commit
2e5964514a
20
shell.nix
20
shell.nix
@ -16,7 +16,19 @@ let
|
||||
'';
|
||||
|
||||
develop = pkgs.writeScriptBin "develop" ''
|
||||
#!${pkgs.zsh}/bin/zsh
|
||||
#!${pkgs.zsh}/bin/zsh -e
|
||||
|
||||
basePath=$(pwd)
|
||||
exec 4<>''${basePath}/.develop.env
|
||||
|
||||
flockRes=
|
||||
set +e
|
||||
${pkgs.util-linux}/bin/flock -en 4; flockRes=$?
|
||||
set -e
|
||||
if [[ ''${flockRes} -ne 0 ]]; then
|
||||
echo "Could not take exclusive lock; is another develop running?" >&2
|
||||
exit ''${flockRes}
|
||||
fi
|
||||
|
||||
cleanup() {
|
||||
set +e -x
|
||||
@ -32,10 +44,6 @@ let
|
||||
|
||||
trap cleanup EXIT
|
||||
|
||||
basePath=$(pwd)
|
||||
|
||||
echo "" > ''${basePath}/.develop.env
|
||||
|
||||
export PORT_OFFSET=$(((16#$(whoami | sha256sum | head -c 16)) % 1000))
|
||||
|
||||
if [[ -z "$PGHOST" ]]; then
|
||||
@ -140,7 +148,7 @@ let
|
||||
|
||||
set -xe
|
||||
|
||||
cat >> ''${basePath}/.develop.env <<EOF
|
||||
cat >&4 <<EOF
|
||||
PORT_OFFSET=''${PORT_OFFSET}
|
||||
|
||||
PGHOST=''${pgSockDir}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user