Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
clinicaltrials
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
david Chavalarias
clinicaltrials
Commits
cd8fd44e
Commit
cd8fd44e
authored
Nov 22, 2016
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finished wsgi mounting of the app (finally using gunicorn instead of uwsgi)
parent
6238dd47
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
122 additions
and
9 deletions
+122
-9
README.md
README.md
+53
-5
nginx_conf.md
doc/nginx_conf.md
+61
-0
server_comex_registration.py
server_comex_registration.py
+6
-4
requirements.txt
setup/requirements.txt
+2
-0
No files found.
README.md
View file @
cd8fd44e
...
...
@@ -9,20 +9,68 @@ This folder contains nov 2016 registration form server
-
the registration credentials are transmitted to a doors prototype
-
the answers are POSTed back to server that writes new users in a local DB
More info in
`docs/`
directory
More info in
`doc/`
directory
-------
### Setting up the server on an nginx server
#### Running in dev
First we need to run the app
```
# install prerequisites
> sudo apt install python3
> sudo apt install python3-virtualenv
# start a virtualenv
> virtualenv --python=/usr/bin/python3 setup/regcomex_venv
> source setup/regcomex_venv/bin/activate
# additional requirements
(regcomex_venv) > pip3 install -r setup/requirements.txt
# run the app ----------------------------------------------------------
(regcomex_venv) > gunicorn -b 127.0.0.1:9090 server_comex_registration:app
# ----------------------------------------------------------
```
# in a virtualenv or a dedicated VM
pip3 install uwsgi flask
The form server is now accessible locally on
`127.0.0.1:9090/regcomex`
(the default ROUTE_PREFIX is /regcomex, but TODO can be changed in config file)
#### Running in prod
Secondly we ask nginx to reverse-proxy our app
This is a minimal conf (cf
[
detailed doc
](
https://github.com/moma/regcomex/blob/master/doc/nginx_conf.md
)
for real-life conf)
```
# nginx exemple
server {
listen 80;
location /$ROUTE_PREFIX {
proxy_pass http://127.0.0.1:9090;
}
}
```
-------
### Setting up the doors connection
TODO config file for the doors api routes
-------
### Connecting the data to *communityexplorer.org*
Currently the data is collected in
`data/registered.db`
The communityexplorer.org app is using a separate DB from legacy wiki csv
(cf
[
detailed doc
](
https://github.com/moma/regcomex/blob/master/doc/nginx_conf.md
)
for real-life conf)
**TODO:**
connect the two
-------
(c) 2016 ISCPIF-CNRS
**contact**
romain.loth@iscpif.fr
(c) 2016 ISCPIF-CNRS
doc/nginx_conf.md
0 → 100644
View file @
cd8fd44e
### 1) Install nginx
```
sudo service apache2 stop
sudo apt install nginx-full # contains uwsgi http module
# check the status
systemctl status nginx.service # or sudo service nginx status
```
### 2) Add regcomex to nginx conf
Create the conf files for regcomex
```
cd /etc/nginx/sites-available
sudo nano regcomex.conf
```
Exemple content to add in
`/etc/nginx/sites-available/regcomex.conf`
```
server {
# your normal server conf here
#listen 80;
#listen [::]:80;
#root /var/www ;
location /regcomex {
proxy_pass http://127.0.0.1:9090; # gunicorn will be serving here
proxy_redirect off;
# useful to keep track of original IP before reverse-proxy
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
# get the logs in a custom place
access_log /home/romain/comex/regcomex/logs/nginx/access.log;
error_log /home/romain/comex/regcomex/logs/nginx/error.log;
}
# faster static serving
location /static {
alias /home/romain/comex/regcomex/static/;
autoindex on;
}
}
```
Finally enable the conf
```
cd /etc/nginx/sites-enabled
sudo ln -s ../sites-available/regcomex.conf
```
server_comex_registration.py
View file @
cd8fd44e
...
...
@@ -62,12 +62,14 @@ COLS = [ ("doors_uid", True, 36),
# ============= views =============
# ------------------------------------------------------------------
# /!\
All routes will be prefixed by comexsomething/reg in prod
/!\
# ------------------------------------------------------------------
# ------------------------------------------------------------------
-----
# /!\
Routes are not prefixed by nginx in prod so we do it ourselves
/!\
# ------------------------------------------------------------------
-----
# prefix must match what nginx conf expects
ROUTE_PREFIX
=
"/regcomex"
@
app
.
route
(
"/"
,
methods
=
[
'GET'
,
'POST'
])
@
app
.
route
(
ROUTE_PREFIX
+
"/"
,
methods
=
[
'GET'
,
'POST'
])
def
one_big_form
():
if
request
.
method
==
'GET'
:
return
render_template
(
"base_form.html"
)
...
...
setup/requirements.txt
0 → 100644
View file @
cd8fd44e
gunicorn
flask
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment