-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/env bash | ||
set -uo pipefail | ||
|
||
await_service() | ||
{ | ||
local start_ts=$(date +%s) | ||
while [ $(date +%s) -lt $((start_ts + $3)) ]; | ||
do | ||
(echo -n > /dev/tcp/$1/$2) > /dev/null | ||
if [[ $? -eq 0 ]]; then | ||
break | ||
fi | ||
sleep 1 | ||
done | ||
local end_ts=$(date +%s) | ||
|
||
if [ $(date +%s) -ge $((start_ts + $3)) ]; then | ||
echo "Timeout occurred while waiting for $1:$2 to become available" | ||
exit 1 | ||
fi | ||
|
||
echo "$1:$2 is available after $((end_ts - start_ts)) seconds" | ||
} | ||
|
||
if [[ $# -ne 3 ]]; then | ||
echo "Usage: $0 <host> <port> <timeout>" | ||
exit 1 | ||
fi | ||
|
||
await_service $1 $2 $3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env bash | ||
set -eo pipefail | ||
|
||
cd /srv/root | ||
|
||
if [ -z "$APP_ENV" ]; then | ||
echo "Please set APP_ENV" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$APP_COMPONENT" ]; then | ||
echo "Please set APP_COMPONENT" | ||
exit 1 | ||
fi | ||
|
||
if [[ $PULL_SECRETS_FROM_VAULT -eq 1 ]]; then | ||
echo "Fetching secrets from vault" | ||
akatsuki vault get beatmaps-service $APP_ENV -o .env | ||
echo "Fetched secrets from vault" | ||
source .env | ||
echo "Sourced secrets from vault" | ||
fi | ||
|
||
if [[ $APP_COMPONENT == "api" ]]; then | ||
exec /scripts/run-api.sh | ||
else | ||
echo "Unknown APP_COMPONENT: $APP_COMPONENT" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
exec ./main.py |