Skip to content

Commit

Permalink
Rename port variable
Browse files Browse the repository at this point in the history
  • Loading branch information
kumaranvpl committed Nov 21, 2024
1 parent c72958f commit b4d7073
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ map $fly_machine_id $sticky_action {

# Main server block
server {
listen $TO_EXPOSE_SERVICE_PORT;
listen $SERVICE_PORT;
server_name localhost;

# Security headers
Expand Down
12 changes: 6 additions & 6 deletions {{cookiecutter.project_slug}}/docker/content/run_fastagency.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ FASTAPI_PORT=${FASTAPI_PORT:-8008}
{% endif %}
{% if "mesop" in cookiecutter.app_type %}
export MESOP_PORT=${MESOP_PORT:-8888}
export TO_EXPOSE_SERVICE_PORT=$MESOP_PORT
export SERVICE_PORT=$MESOP_PORT
{% else %}
export TO_EXPOSE_SERVICE_PORT=$FASTAPI_PORT
export SERVICE_PORT=$FASTAPI_PORT
{% endif %}
# Default number of workers if not set
WORKERS=${WORKERS:-1}
Expand All @@ -24,10 +24,10 @@ echo "Fly machine ID: $FLY_MACHINE_ID"
# Generate nginx config
for ((i=1; i<$WORKERS+1; i++))
do
PORT=$((TO_EXPOSE_SERVICE_PORT + i))
PORT=$((SERVICE_PORT + i))
sed -i "5i\ server 127.0.0.1:$PORT;" nginx.conf.template
done
envsubst '${TO_EXPOSE_SERVICE_PORT},${FLY_MACHINE_ID}' < nginx.conf.template >/etc/nginx/conf.d/default.conf
envsubst '${SERVICE_PORT},${FLY_MACHINE_ID}' < nginx.conf.template >/etc/nginx/conf.d/default.conf
echo "Nginx config:"
cat /etc/nginx/conf.d/default.conf

Expand All @@ -42,7 +42,7 @@ uvicorn {{cookiecutter.project_slug}}.deployment.main_1_nats:app --host 0.0.0.0
# Start multiple single-worker uvicorn instances on consecutive ports
for ((i=1; i<$WORKERS+1; i++))
do
PORT=$((TO_EXPOSE_SERVICE_PORT + i))
PORT=$((SERVICE_PORT + i))
echo "Starting gunicorn on port $PORT"
uvicorn {{cookiecutter.project_slug}}.deployment.main_1_fastapi:app --workers=1 --host 0.0.0.0 --port $PORT > /dev/stdout 2>&1 &
done
Expand All @@ -55,7 +55,7 @@ uvicorn {{cookiecutter.project_slug}}.deployment.main_{% if "nats" in cookiecutt
# Start multiple single-worker gunicorn instances on consecutive ports
for ((i=1; i<$WORKERS+1; i++))
do
PORT=$((TO_EXPOSE_SERVICE_PORT + i))
PORT=$((SERVICE_PORT + i))
echo "Starting gunicorn on port $PORT"
gunicorn --workers=1 {{cookiecutter.project_slug}}.deployment.main{% if "nats" in cookiecutter.app_type %}_3_mesop{% elif "fastapi" in cookiecutter.app_type %}_2_mesop{% endif %}:app --bind 0.0.0.0:$PORT > /dev/stdout 2>&1 &
done
Expand Down

0 comments on commit b4d7073

Please sign in to comment.