From c75550e87e158d4bea1f2c2387c68abf5dc8e47d Mon Sep 17 00:00:00 2001 From: spelhate Date: Tue, 26 May 2020 09:35:16 +0200 Subject: [PATCH] Update to use gunicorn with both backend frontend --- INSTALL.md | 41 +++++++++++++++++++++++++++++++++++++++++ dispatcher.py | 15 +++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 dispatcher.py diff --git a/INSTALL.md b/INSTALL.md index 02fc2b3..2fc27a5 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -50,4 +50,45 @@ Test backend test http://localhost:5000/api + + +Tester frontend & backend +-------------------------- + + $ python3 dispatcher.py + + test http://localhost:5000/api + test http://localhost:5000/admin/ + test http://localhost:5000/mreport/sample/ECLUSE_1 + + +gunicorn +-------- + + + $ gunicorn -b 0.0.0.0:5000 dispatcher + + ```Create a .service file for the api. (/etc/systemd/system/mreport.service):``` + +``` +[Unit] +Description=mreport +After=network.target + +[Service] +User=mreport +Restart=on-failure +WorkingDirectory=/tmp/ +ExecStart=/home/mreport/mreport/venv/bin/gunicorn -b 0.0.0.0:5000 dispatcher + +[Install] +WantedBy=multi-user.target +``` + + +```Enable and start the service``` + + $ sudo systemctl daemon-reload + $ sudo systemctl enable mreport + $ systemctl start mreport \ No newline at end of file diff --git a/dispatcher.py b/dispatcher.py new file mode 100644 index 0000000..95fcc22 --- /dev/null +++ b/dispatcher.py @@ -0,0 +1,15 @@ +from werkzeug.middleware.dispatcher import DispatcherMiddleware +from werkzeug.serving import run_simple +from frontend import app as front +from backend import app as back + +application = DispatcherMiddleware(front, {'/api': back }) + +if __name__ == '__main__': + run_simple( + hostname='localhost', + port=5000, + application=application, + use_reloader=True, + use_debugger=True, + use_evalex=True) \ No newline at end of file