Skip to content

Commit

Permalink
Update to use gunicorn with both backend frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
spelhate committed May 26, 2020
1 parent 39ba175 commit c75550e
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
41 changes: 41 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

15 changes: 15 additions & 0 deletions dispatcher.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit c75550e

Please sign in to comment.