Skip to content

Commit

Permalink
api: forward ECS metadata URI
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaume committed Aug 26, 2021
1 parent dfcb871 commit ec1cc2c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
16 changes: 11 additions & 5 deletions mpcontribs-api/main.sh
@@ -1,11 +1,17 @@
#!/bin/bash

supervisorctl start api
# TODO only start worker/scheduler on first AWS task/container?

if [ ! -z ${ECS_CONTAINER_METADATA_URI_V4} ]; then
http ${ECS_CONTAINER_METADATA_URI_V4}
echo "METADATA URI: ${METADATA_URI}"

if [ -z ${METADATA_URI} ]; then
# in docker-compose stack with one task
supervisorctl start worker
supervisorctl start scheduler
else
# in AWS Fargate with potentially multiple tasks
http ${METADATA_URI}
supervisorctl start worker
supervisorctl start scheduler
fi

supervisorctl start worker
supervisorctl start scheduler
1 change: 1 addition & 0 deletions mpcontribs-api/supervisord.conf
Expand Up @@ -45,6 +45,7 @@ stderr_logfile_maxbytes=0
[program:main]
command=./main.sh
directory=/app
environment=METADATA_URI=%(ENV_ECS_CONTAINER_METADATA_URI_V4)s
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
stderr_logfile=/dev/fd/2
Expand Down

0 comments on commit ec1cc2c

Please sign in to comment.