Skip to content

Commit de58dd1

Browse files
author
Dan Kelley
committed
moved CMDs to startServer to allow logging and more control
1 parent 7f37efe commit de58dd1

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed

src/server/Dockerfile

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,10 @@ RUN chmod -R 777 /app/static
3838
COPY . /paws-data-pipeline/server
3939

4040
RUN chmod 777 /paws-data-pipeline/server
41+
42+
RUN chmod +x bin/startServer.sh
4143
# RUN ufw allow 5000
4244
WORKDIR /app
4345

44-
# --uid uwsgi
45-
CMD uwsgi --http-socket :5000 --plugin python38 --module wsgi:app --chdir /app --pythonpath .
46-
# we may want to switch this to a script which logs output, etc?
47-
48-
RUN set FLASK_APP=server/app.py
49-
RUN export FLASK_APP
50-
51-
# This abomination ensures that the PG server has finished its restart cycle
52-
CMD echo "SLEEPING 10"; sleep 10; echo "WAKING"; alembic upgrade head ; python -m flask run --host=0.0.0.0 --no-reload
53-
54-
# --no-reload prevents Flask restart, which usually happens in middle of create_base_users()
55-
#TODO: SECURITY - ensure we are not running in debug mode in production
46+
CMD bin/startServer.sh
47+
#>> start.log 2>&1

src/server/app.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
jwt = JWTManager(app)
1414

1515

16-
# def create_app():
1716
app.secret_key = APP_SECRET_KEY
1817
app.config["MAX_CONTENT_LENGTH"] = 500 * 1024 * 1024 # 500 Megs
1918
app.config["SEND_FILE_MAX_AGE_DEFAULT"] = 0

src/server/bin/startServer.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
# we may want to switch this to a script which logs output, etc?
3+
echo "------------STARTING `date` ------------------"
4+
set FLASK_APP=server/app.py
5+
export FLASK_APP
6+
7+
# This abomination ensures that the PG server has finished its restart cycle
8+
echo "SLEEPING.. WAITING FOR DB"; sleep 5; echo "WAKING"; alembic upgrade head; echo "DB SETUP";
9+
#; python -m flask run --host=0.0.0.0 --no-reload
10+
11+
# --no-reload prevents Flask restart, which usually happens in middle of create_base_users()
12+
#TODO: SECURITY - ensure we are not running in debug mode in production
13+
uwsgi --http-socket :5000 --plugin python38 --module wsgi:app --chdir /app --pythonpath .

src/server/wsgi.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
from app import create_app
2-
3-
app = create_app()
1+
from app import app
42

53
if __name__ == "__main__":
64
app.run()

0 commit comments

Comments
 (0)