Ver código fonte

Merge pull request #11 from tracim/feature/automated_setup_and_better_uwsgi_doc

PhilippeAccorsi 6 anos atrás
pai
commit
5ccd7c67d3
Nenhuma conta conectada ao e-mail do autor de commit
4 arquivos alterados com 145 adições e 7 exclusões
  1. 53 7
      backend/README.md
  2. 23 0
      backend/doc/known_issues.md
  3. 52 0
      backend_lib.sh
  4. 17 0
      setup_default_backend.sh

+ 53 - 7
backend/README.md Ver arquivo

@@ -81,21 +81,33 @@ create wsgidav configuration file for webdav:
81 81
 
82 82
     cp wsgidav.conf.sample wsgidav.conf
83 83
 
84
-## Run Tracim_backend ##
84
+## Run Tracim_backend With Uwsgi : great for production ##
85 85
 
86
-### With Uwsgi ###
87 86
 
88
-Run all services with uwsgi
87
+#### Install Uwsgi
88
+
89
+You can either install uwsgi with pip or with you distrib package manager:
89 90
 
90 91
     # install uwsgi with pip ( unneeded if you already have uwsgi with python3 plugin enabled)
91 92
     sudo pip3 install uwsgi
93
+
94
+or on debian 9 :
95
+
96
+    # install uwsgi on debian 9
97
+    sudo apt install uwsgi uwsgi-plugin-python3
98
+
99
+### All in terminal way ###
100
+
101
+
102
+Run all services with uwsgi
103
+
92 104
     # set tracim_conf_file path
93 105
     export TRACIM_CONF_PATH="$(pwd)/development.ini"
94 106
     export TRACIM_WEBDAV_CONF_PATH="$(pwd)/wsgidav.conf"
95 107
     # pyramid webserver
96
-    uwsgi -d /tmp/tracim_web.log --http-socket :6543 --wsgi-file wsgi/web.py -H env --pidfile /tmp/tracim_web.pid
108
+    uwsgi -d /tmp/tracim_web.log --http-socket :6543 --plugin python3 --wsgi-file wsgi/web.py -H env --pidfile /tmp/tracim_web.pid
97 109
     # webdav wsgidav server
98
-    uwsgi -d /tmp/tracim_webdav.log --http-socket :3030 --wsgi-file wsgi/webdav.py -H env --pidfile /tmp/tracim_webdav.pid
110
+    uwsgi -d /tmp/tracim_webdav.log --http-socket :3030 --plugin python3 --wsgi-file wsgi/webdav.py -H env --pidfile /tmp/tracim_webdav.pid
99 111
 
100 112
 to stop them:
101 113
 
@@ -104,7 +116,37 @@ to stop them:
104 116
     # webdav wsgidav server
105 117
     uwsgi --stop /tmp/tracim_webdav.pid
106 118
 
107
-### With Waitress (legacy way, usefull for debug) ###
119
+## With Uwsgi ini script file ##
120
+
121
+You can also preset uwsgi config for tracim, this way, creating this kind of .ini file:
122
+
123
+    # You need to replace <PATH> with correct absolute path
124
+    [uwsgi]
125
+    plugins = python3
126
+    chdir = <PATH>/tracim_v2/backend/
127
+    module = wsgi.web:application
128
+    home = <PATH>/tracim_v2/backend/env/
129
+    env = TRACIM_CONF_PATH=<PATH>/tracim_v2/backend/development.ini
130
+
131
+and :
132
+
133
+    # You need to replace <PATH> with correct absolute path
134
+    [uwsgi]
135
+    plugins = python3
136
+    chdir = <PATH>/tracim_v2/backend/
137
+    module = wsgi.webdav:application
138
+    home = <PATH>/tracim_v2/backend/env/
139
+    env = TRACIM_CONF_PATH=<PATH>/tracim_v2/backend/development.ini
140
+    env = TRACIM_WEBDAV_CONF_PATH=<PATH>/tracim_v2/backend/wsgidav.conf
141
+
142
+You can then run the process this way :
143
+
144
+    # You need to replace <WSGI_CONF_WEB> with correct path
145
+    uwsgi --ini <WSGI_CONF_WEB>.ini --http-socket :6543
146
+    # You need to replace <WSGI_CONF_WEBDAV> with correct path
147
+    uwsgi --ini <WSGI_CONF_WEBDAV>.ini --http-socket :3030
148
+
149
+### Run Tracim_Backend with Waitress : legacy way, usefull for debug and dev ###
108 150
 
109 151
 run tracim_backend web api:
110 152
 
@@ -159,4 +201,8 @@ For example, with default config:
159 201
 
160 202
 In Tracim, only some user can access to some informations, this is also true in
161 203
 Tracim REST API. you can check the [roles documentation](doc/roles.md) to check
162
-what a specific user can do.
204
+what a specific user can do.
205
+
206
+# Known issues
207
+
208
+see [here](doc/known_issues.md)

+ 23 - 0
backend/doc/known_issues.md Ver arquivo

@@ -0,0 +1,23 @@
1
+# Known issue with Tracim Backend
2
+
3
+## Uwsgi
4
+
5
+### plaster.exceptions.LoaderNotFound
6
+
7
+If you obtain error with :
8
+
9
+
10
+    plaster.exceptions.LoaderNotFound: Could not find a matching loader for the scheme "file+ini"".
11
+
12
+
13
+you most probably don't set correctly TRACIM_CONF_PATH or TRACIM_WEBDAV_CONF_PATH.
14
+You have to set a correct absolute path.
15
+be careful for uwsgi ini file :
16
+
17
+
18
+    # incorrect
19
+    env = TRACIM_CONF_PATH="/home/me/tracim_v2/backend/development.ini"
20
+
21
+    # correct
22
+    env = TRACIM_CONF_PATH=/home/me/tracim_v2/backend/development.ini
23
+

+ 52 - 0
backend_lib.sh Ver arquivo

@@ -0,0 +1,52 @@
1
+. bash_library.sh # source bash_library.sh
2
+
3
+function install_backend_system_dep {
4
+    log "install base debian-packaged-dep for backend..."
5
+    sudo apt update
6
+    sudo apt install -y python3 python3-venv python3-dev python3-pip
7
+    sudo apt install -y redis-server
8
+
9
+    log "install deps for dealing with most preview..."
10
+    sudo apt install -y zlib1g-dev libjpeg-dev
11
+    sudo apt install -y imagemagick libmagickwand-dev ghostscript
12
+    sudo apt install -y libreoffice # most office documents file and text format
13
+    sudo apt install -y inkscape # for .svg files.
14
+}
15
+
16
+function setup_pyenv {
17
+   log "setup python3 env.."
18
+   python3 -m venv env
19
+   source env/bin/activate
20
+}
21
+
22
+function install_backend_python_packages {
23
+    pip install --upgrade pip setuptools
24
+
25
+    log "install tracim-backend (sqlite_backend)..."
26
+    pip install -e ".[testing]"
27
+}
28
+
29
+function setup_config_file {
30
+    log "configure tracim with default conf..."
31
+    if [ ! -f development.ini ]; then
32
+       log "generate missing development.ini ..."
33
+       cp development.ini.sample development.ini
34
+    fi
35
+
36
+    if [ ! -f wsgidav.conf ]; then
37
+       log "generate missing wsgidav.conf ..."
38
+       cp wsgidav.conf.sample wsgidav.conf
39
+    fi
40
+}
41
+
42
+function setup_db {
43
+    result=$(alembic -c development.ini current)
44
+    if [ $? -eq 0 ] && [ ! "$result" == '' ]; then
45
+       log "check database migration..."
46
+       alembic -c development.ini upgrade head
47
+    else
48
+       log "database seems missing, init it..."
49
+       tracimcli db init
50
+       alembic -c development.ini stamp head
51
+    fi
52
+}

+ 17 - 0
setup_default_backend.sh Ver arquivo

@@ -0,0 +1,17 @@
1
+#!/bin/bash
2
+. bash_library.sh # source bash_library.sh
3
+. backend_lib.sh # source backend_lib.sh
4
+
5
+install_backend_system_deb
6
+
7
+log "go to backend subdir.."
8
+cd backend || exit 1;
9
+
10
+
11
+install_backend_system_dep
12
+setup_pyenv
13
+install_backend_python_packages
14
+setup_config_file
15
+setup_db
16
+
17
+log "backend of tracim was correctly set-up."