refactor: Setup using gunicorn
This commit is contained in:
+2
-1
@@ -1,3 +1,4 @@
|
|||||||
tailwindcss
|
tailwindcss
|
||||||
static/output.css
|
static/output.css
|
||||||
.env
|
.env
|
||||||
|
__pycache__
|
||||||
+1
-1
@@ -12,4 +12,4 @@ RUN pip install -r requirements.txt \
|
|||||||
&& ./tailwindcss -i ./static/input.css -o ./static/output.css --content "./templates/*.html" --minify \
|
&& ./tailwindcss -i ./static/input.css -o ./static/output.css --content "./templates/*.html" --minify \
|
||||||
&& rm tailwindcss
|
&& rm tailwindcss
|
||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
CMD ["python", "app.py"]
|
CMD ["gunicorn", "--workers", "2", "--bind", "0.0.0.0:5000", "app:app", "--log-level", "warning"]
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import pytz
|
import pytz
|
||||||
|
import logging
|
||||||
from flask import Flask, render_template, request, redirect, url_for, session, jsonify
|
from flask import Flask, render_template, request, redirect, url_for, session, jsonify
|
||||||
from datetime import datetime, date as datedate, datetime as dt
|
from datetime import datetime, date as datedate, datetime as dt
|
||||||
import mysql.connector
|
import mysql.connector
|
||||||
@@ -22,6 +23,8 @@ mysql_config = {
|
|||||||
'database': os.getenv('MYSQL_DATABASE', 'echolog')
|
'database': os.getenv('MYSQL_DATABASE', 'echolog')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logging.basicConfig(level=logging.INFO, format='[%(asctime)s] %(levelname)s in %(module)s: %(message)s')
|
||||||
|
|
||||||
def get_db_connection():
|
def get_db_connection():
|
||||||
return mysql.connector.connect(**mysql_config)
|
return mysql.connector.connect(**mysql_config)
|
||||||
|
|
||||||
@@ -189,6 +192,4 @@ def delete_entry(entry_id):
|
|||||||
return redirect(url_for('index'))
|
return redirect(url_for('index'))
|
||||||
|
|
||||||
init_db()
|
init_db()
|
||||||
|
logging.info('EchoLog started up successfully.')
|
||||||
if __name__ == '__main__':
|
|
||||||
app.run(host='0.0.0.0', port=5000)
|
|
||||||
+2
-1
@@ -1,4 +1,5 @@
|
|||||||
Flask
|
Flask
|
||||||
mysql-connector-python
|
mysql-connector-python
|
||||||
python-dotenv
|
python-dotenv
|
||||||
pytz
|
pytz
|
||||||
|
gunicorn
|
||||||
@@ -4,4 +4,4 @@ echo "Generating CSS..."
|
|||||||
./tailwindcss -i ./static/input.css -o ./static/output.css --content "./templates/*.html" --minify
|
./tailwindcss -i ./static/input.css -o ./static/output.css --content "./templates/*.html" --minify
|
||||||
|
|
||||||
echo "Starting app..."
|
echo "Starting app..."
|
||||||
python3 app.py
|
gunicorn --workers 2 --bind 0.0.0.0:5000 app:app --log-level warning
|
||||||
Reference in New Issue
Block a user