chore: offset ports used in nix-shell

This commit is contained in:
Gregor Kleen 2021-05-06 12:33:26 +02:00
parent e95abc97ee
commit c7782d0194
2 changed files with 11 additions and 11 deletions

View File

@ -24,7 +24,7 @@ let
shellHook = ''
export PROMPT_INFO="${oldAttrs.name}"
export EDITOR=emacsclient
export PORT_OFFSET=$(((16#$(whoami | sha256sum | head -c 16)) % 1000))
cleanup() {
set +e -x
@ -63,14 +63,14 @@ let
if [[ -z "$WIDGET_MEMCACHED_HOST" ]]; then
set -xe
memcached -l localhost -p 11211 &>/dev/null &
memcached -l localhost -p $(($PORT_OFFSET + 11211)) &>/dev/null &
widget_memcached_pid=$?
cleanup_widget_memcached() {
[[ -n "$widget_memcached_pid" ]] && kill $widget_memcached_pid
}
export WIDGET_MEMCACHED_HOST=localhost WIDGET_MEMCACHED_PORT=11211
export WIDGET_MEMCACHED_HOST=localhost WIDGET_MEMCACHED_PORT=$(($PORT_OFFSET + 11211))
set +xe
fi
@ -78,14 +78,14 @@ let
if [[ -z "$SESSION_MEMCACHED_HOST" ]]; then
set -xe
memcached -l localhost -p 11212 &>/dev/null &
memcached -l localhost -p $(($PORT_OFFSET + 11212)) &>/dev/null &
session_memcached_pid=$?
cleanup_session_memcached() {
[[ -n "$session_memcached_pid" ]] && kill $session_memcached_pid
}
export SESSION_MEMCACHED_HOST=localhost SESSION_MEMCACHED_PORT=11212
export SESSION_MEMCACHED_HOST=localhost SESSION_MEMCACHED_PORT=$(($PORT_OFFSET + 11212))
set +xe
fi
@ -93,14 +93,14 @@ let
if [[ -z "$MEMCACHED_HOST" ]]; then
set -xe
memcached -l localhost -p 11213 &>/dev/null &
memcached -l localhost -p $(($PORT_OFFSET + 11213)) &>/dev/null &
memcached_pid=$?
cleanup_session_memcached() {
[[ -n "$memcached_pid" ]] && kill $memcached_pid
}
export MEMCACHED_HOST=localhost MEMCACHED_PORT=11212
export MEMCACHED_HOST=localhost MEMCACHED_PORT=$(($PORT_OFFSET + 11212))
set +xe
fi
@ -119,12 +119,12 @@ let
export MINIO_ACCESS_KEY=$(${pkgs.pwgen}/bin/pwgen -s 16 1)
export MINIO_SECRET_KEY=$(${pkgs.pwgen}/bin/pwgen -s 32 1)
minio server --address localhost:9000 ''${MINIO_DIR} &>''${MINIO_LOGFILE} &
minio server --address localhost:$(($PORT_OFFSET + 9000)) ''${MINIO_DIR} &>''${MINIO_LOGFILE} &
minio_pid=$?
sleep 1
export UPLOAD_S3_HOST=localhost UPLOAD_S3_PORT=9000 UPLOAD_S3_SSL=false UPLOAD_S3_KEY_ID=''${MINIO_ACCESS_KEY} UPLOAD_S3_KEY=''${MINIO_SECRET_KEY}
export UPLOAD_S3_HOST=localhost UPLOAD_S3_PORT=$(($PORT_OFFSET + 9000)) UPLOAD_S3_SSL=false UPLOAD_S3_KEY_ID=''${MINIO_ACCESS_KEY} UPLOAD_S3_KEY=''${MINIO_SECRET_KEY}
set +xe
fi

View File

@ -31,10 +31,10 @@ fi
if ! [ -z "$(which yesod)" ]
then
yesod devel $@
yesod devel -p $((${PORT_OFFSET:-0} + 3000)) -q $((${PORT_OFFSET:-0} + 3443)) $@
elif ! [ -z "$(which stack)" ]
then
stack exec -- yesod devel $@
stack exec -- yesod devel -p $((${PORT_OFFSET:-0} + 3000)) -q $((${PORT_OFFSET:-0} + 3443)) $@
else
exit 1
fi