-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removing FlaskGroup.cli + adding run.sh
- Loading branch information
Showing
8 changed files
with
85 additions
and
19 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
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
container_commands: | ||
01_initdb: | ||
command: "source /var/app/venv/*/bin/activate && python3 application.py create_all" | ||
command: "source /var/app/venv/*/bin/activate && python3 init_db.py" | ||
leader_only: true |
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
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,10 @@ | ||
from gevent import monkey | ||
monkey.patch_all() | ||
|
||
from flask import Flask | ||
from app import create_app, db | ||
|
||
if __name__ == "__main__": | ||
application = create_app() | ||
with application.app_context(): | ||
db.create_all() |
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
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
upstream flask_nodes { | ||
ip_hash; | ||
|
||
server flask_1:5000; | ||
server flask:5000; | ||
server flask_2:5000; | ||
} | ||
|
||
|
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,65 @@ | ||
#!/bin/bash | ||
|
||
# default values | ||
ENVIRONMENT="prod" | ||
DETACH=false | ||
VOLUMES=false | ||
|
||
# parse command line arguments | ||
while [[ $# -gt 0 ]]; do | ||
key="$1" | ||
|
||
case $key in | ||
-e|--env) | ||
ENVIRONMENT="$2" | ||
shift | ||
;; | ||
-d|--detach) | ||
DETACH=true | ||
;; | ||
-v|--volumes) | ||
VOLUMES=true | ||
;; | ||
*) | ||
# unknown option | ||
echo "Unknown option: $1" | ||
exit 1 | ||
;; | ||
esac | ||
shift | ||
done | ||
|
||
# run the corresponding docker-compose file | ||
case $ENVIRONMENT in | ||
"debug") | ||
DOCKER_COMPOSE_FILE="docker-compose.debug.yml" | ||
;; | ||
"dev") | ||
DOCKER_COMPOSE_FILE="docker-compose.dev.yml" | ||
;; | ||
"prod") | ||
DOCKER_COMPOSE_FILE="docker-compose.prod.yml" | ||
;; | ||
*) | ||
echo "Invalid environment. Use 'debug', 'dev', or 'prod'." | ||
exit 1 | ||
;; | ||
esac | ||
|
||
# kill the previous containers and clear the volumes if requested | ||
if [ "$VOLUMES" = false ]; then | ||
docker-compose -f "$DOCKER_COMPOSE_FILE" down | ||
else | ||
docker-compose -f "$DOCKER_COMPOSE_FILE" down -v | ||
fi | ||
|
||
# build and start the services | ||
docker-compose -f "$DOCKER_COMPOSE_FILE" up --build -d | ||
|
||
# run create_all script | ||
docker-compose -f "$DOCKER_COMPOSE_FILE" exec flask python init_db.py | ||
|
||
# if not in detached mode, show the real-time logs in the current shell | ||
if [ "$DETACH" = false ]; then | ||
docker-compose -f "$DOCKER_COMPOSE_FILE" logs -f | ||
fi |