README.md 1.09 KB
Newer Older
Ossi Laine's avatar
Ossi Laine committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Online survey creation tool

### Prerequisites

Flask app with MariaDB 

Check requirements.txt

### Installing

Install python packages with pip and preferably in virtual environment:
```
virtualenv venv
source venv/bin/activate
pip install -r requirements.txt
``` 

### Deployment

There are multiple deployment options, but one working solution is:
nginx + gunicorn (with gevent worker) 

Create systemd startup script in '/etc/systemd/system/gunicorn.service'

```
[Unit]
Description=Gunicorn instance to serve flask application
After=network.target

[Service]
User=nginx
WorkingDirectory=/srv/rating
Environment="PATH=/srv/rating/venv/bin"
ExecStart=/srv/rating/venv/bin/gunicorn run:app -b localhost:8000 -k gevent -w 1

[Install]
WantedBy=multi-user.target
```

Run 'systemctl daemon-reload' to reload units.

Enable and start gunicorn service:
```
service gunicorn enable
service gunicorn start
```

### Logs

Error logs are saved to application folder (/srv/rating/logs/) 

Optionally with journalctl:
journalctl -u gunicorn.service 

### Restart server after updates

```
service gunicorn restart
```