Randomize the ports

This should help with port colitions when running multiple projects at once.
This commit is contained in:
Andreas Zweili 2023-07-22 15:58:26 +02:00
parent 86e0ae7c5b
commit 8bf4ee6bbe
4 changed files with 8 additions and 4 deletions

2
.envrc
View File

@ -11,4 +11,6 @@ layout_postgres() {
}
layout postgres
export PROJECT_DIR=$(pwd)
export WEBPORT=$(($RANDOM + 1100))
export PGPORT=$(($WEBPORT + 100))
watch_file "$PGDATA/postgresql.conf"

View File

@ -1,2 +1,2 @@
web: python ./src/manage.py runserver 0.0.0.0:8000
db: postgres
web: python ./src/manage.py runserver 0.0.0.0:$WEBPORT
db: postgres -p $PGPORT

5
dev.sh
View File

@ -3,8 +3,9 @@
run () {
setup
find . -name __pycache__ -o -name "*.pyc" -delete
sudo iptables -I INPUT -p tcp --dport 8000 -j ACCEPT
overmind start
sudo iptables -I INPUT -p tcp --dport $WEBPORT -j ACCEPT
overmind start -D
echo "http://$(hostname -f):$WEBPORT"
}
setup () {

View File

@ -31,5 +31,6 @@ DATABASES = {
"NAME": "django",
"USER": os.environ.get("USER"),
"HOST": os.environ.get("PGHOST"),
"PORT": os.environ.get("PGPORT"),
}
}