@@ -78,11 +78,10 @@ System requirements
78
78
79
79
* an account for the web app that can create databases and tables
80
80
81
- - git
81
+ - git, unless the Funkfeuer application, common node database, and tapyr are
82
+ all installed via Debian packages or with ``pip install ``.
82
83
83
- - Python (2.7 or 3.5)
84
-
85
- * `rsclib ` is not Python 3 compatible, all other code is
84
+ - Python (2.7 or 3.5+)
86
85
87
86
- Python packages
88
87
@@ -96,7 +95,7 @@ System requirements
96
95
97
96
* `flup `_
98
97
99
- optional, necessary when fcgi is used
98
+ only necessary when fcgi is used
100
99
101
100
* `jinja2 `_
102
101
@@ -125,6 +124,8 @@ System requirements
125
124
optional, only used during deployment for minimization of CSS and
126
125
Javascript files
127
126
127
+ **should be used to make webserver responses smaller **
128
+
128
129
`rcssmin ` and `rjsmin ` are much faster than `cssmin ` and `jsmin `
129
130
130
131
* `rsclib `_
@@ -170,62 +171,68 @@ Debian-specific in other parts.
170
171
If you are running in a virtual machine, you need at least 384 MB of
171
172
RAM, 256 MB isn't enough.
172
173
174
+ Debian Stretch
175
+ ~~~~~~~~~~~~~~~
173
176
174
- Debian Jessie
175
- ~~~~~~~~~~~~~
177
+ You can install for either Python-2 or Python-3. In the following, we will
178
+ assume an install for nginx and uwsgi.
176
179
177
- Almost all packages can be installed via the Debian Jessie
178
- installer::
180
+ For Python-2::
179
181
180
- $ apt-get --no-install-recommends install \
181
- git postgresql python-babel python-bcrypt python-bs4 \
182
- python-dateutil python-docutils python-jinja2 \
183
- python-pip python-plumbum python-psycopg2 python-pyquery \
184
- python-rcssmin python-rjsmin python-sqlalchemy python-tz \
185
- python-werkzeug
182
+ # export pv=''
186
183
187
- Depending on the webserver you want to use, either ::
184
+ For Python-3 ::
188
185
189
- $ apt-get --no-install-recommends install \
190
- uwsgi uwsgi-plugin-python
191
- $ apt-get --no-install-recommends -t jessie-backports install \
192
- nginx-full nginx-doc
186
+ # export pv='3'
193
187
194
- or::
188
+ Almost all packages can be installed via the Debian Stretch
189
+ installer::
195
190
196
- $ apt-get --no-install-recommends install \
197
- apache2-mpm-worker libapache2-mod-fcgid python-flup
191
+ # apt-get install \
192
+ git postgresql sudo \
193
+ python${pv}-babel python${pv}-bcrypt python${pv}-bs4 \
194
+ python${pv}-dateutil python${pv}-docutils python${pv}-jinja2 \
195
+ python${pv}-pip python${pv}-plumbum python${pv}-psycopg2 \
196
+ python${pv}-pyquery python${pv}-rcssmin python${pv}-rjsmin \
197
+ python${pv}-setuptools python${pv}-sqlalchemy python${pv}-tz \
198
+ python${pv}-virtualenv python${pv}-werkzeug \
199
+ nginx-full nginx-doc uwsgi uwsgi-plugin-python${pv}
198
200
199
201
Other packages can be installed using ``pip ``::
200
202
201
- $ pip install rsclib
202
-
203
+ # pip${pv} install rsclib
203
204
204
205
How to install
205
206
--------------
206
207
207
208
Create user and database user permitted to create databases. For instance,
208
209
for Funkfeuer Wien::
209
210
210
- $ adduser --system --disabled-password --home /srv/ffw --shell /bin/bash --group ffw
211
- $ adduser --disabled-password --home /srv/ffw --shell /bin/false --ingroup ffw ffw-r
212
- $ sudo -u postgres createuser -d ffw -P
211
+ # adduser --system --disabled-password --home /srv/ffw${pv} \
212
+ --shell /bin/bash --group ffw${pv}
213
+
214
+ # adduser --disabled-password --home /srv/ffw${pv} --no-create-home \
215
+ --shell /bin/false --ingroup ffw${pv} --quiet ffw${pv}-r
216
+
217
+ # sudo -u postgres createuser -d ffw${pv} -P
213
218
214
219
Note: Depending on your setup the createuser command has to be executed by
215
220
a different user.
216
221
217
- Assuming an account `ffw ` located in /srv/ffw, you'll need something
218
- like the following::
222
+ Assuming an account `ffw${pv} ` located in /srv/ffw${pv} , you'll need
223
+ something like the following::
219
224
220
- ### Logged in as `ffw`
221
- $ cd
225
+ # su - ffw${pv}
222
226
223
- ### Define config
224
- $ vi .ffw.config
225
- ### Add the lines (using the appropriate values for **your** install)::
226
- ### No leading spaces are allowed
227
+ $ export pv='3' ### or '' if you use Python-2
228
+ $ alias python="python${pv}"
229
+
230
+ ### Define config
231
+ $ vi .ffw.config
232
+ ### Add the lines (using the appropriate values for **your** install)::
233
+ ### No leading spaces are allowed
227
234
cookie_salt = 'some random value, e.g., the result of uuid.uuid4 ()'
228
- db_name = "ffw"
235
+ db_name = "ffw<pv>" ### best to use the account name here
229
236
db_url = "postgresql://<account>:<password>@localhost"
230
237
### email_from:
231
238
### - `From` address for emails sent, e.g., password reset
@@ -235,45 +242,39 @@ like the following::
235
242
languages = "de", "en"
236
243
locale_code = "de"
237
244
smtp_server = "localhost"
238
- target_db_url = db_url
239
- time_zone = "Mars/Olympos Mons "
245
+ target_db_url = db_url ### Must be equal to `db_name` here
246
+ time_zone = "Europe/Vienna "
240
247
241
248
Then we continue with the setup of an active and a passive branch of the
242
249
web application. With this you can upgrade the passive application while
243
- the active application is running without risking a non-functional
250
+ the active application is running; without risking a non-functional
244
251
system should something go wrong during the upgrade::
245
252
246
- ### create a directory with an `active` and `passive` branch of the
247
- ### web application
248
- ###
249
- ### * the active branch will be the one that serves apache requests
250
- ###
251
- ### * the passive branch can be used for updating the software and
252
- ### testing it. It all works will the branches can be switched
253
- ###
254
-
255
- $ mkdir fcgi
256
- $ mkdir -p v/1/www/media
257
- $ ln -s v/1 active
258
- $ ln -s v/2 passive
259
- $ git clone git://github.com/Tapyr/tapyr.git v/1/tapyr
260
- $ git clone git://github.com/FunkFeuer/common-node-db.git v/1/cndb
261
- $ git clone git://github.com/FunkFeuer/Wien.git v/1/www/app
262
- $ (cd v/1/www/media ; ln -s ../app/media/images images)
263
- $ cp -a v/1 v/2
264
-
265
- $ vi active/.ffw.config
266
- ### Add the lines (using the appropriate values for **your** install)::
267
- db_name = "ffw1"
268
- $ vi passive/.ffw.config
269
- db_name = "ffw2"
270
-
271
- ### Define PYTHONPATH
272
- $ export PYTHONPATH=~/active/cndb:~/active/tapyr
273
-
274
- With a small config-file, the deploy-app can automatically create an
275
- Apache configuration file and a fcgi script. You can find sample
276
- config-files in active/www/app/httpd_config/. For instance,
253
+ ### * the active branch will be the one that serves webserver requests
254
+ ###
255
+ ### * the passive branch can be used for updating the software and
256
+ ### testing it. It all works will the branches can be switched
257
+
258
+ $ mkdir -p v/1/www
259
+ $ ln -s v/1 passive
260
+ $ ln -s v/2 active
261
+ $ git clone git://github.com/Tapyr/tapyr.git passive/tapyr
262
+ $ git clone git://github.com/FunkFeuer/common-node-db.git passive/cndb
263
+ $ git clone git://github.com/FunkFeuer/Wien.git passive/www/app
264
+ $ ( cd passive/www ; ln -s app/media ; mkdir -p app/media/v )
265
+ $ cp -a v/1 v/2
266
+
267
+ ### Ensure different `db_name` for v/1 and v/2
268
+ ### (using the appropriate values for **your** install)::
269
+ $ echo 'db_name = "ffw<pv>_a"' > active/.ffw.config
270
+ $ echo 'db_name = "ffw<pv>_b"' > passive/.ffw.config
271
+
272
+ ### Define PYTHONPATH used by the application
273
+ $ export PYTHONPATH=~/active/cndb:~/active/tapyr
274
+
275
+ With a small config-file, the deploy-app can automatically create a
276
+ webserver configuration file and a fcgi/wsgi/uwsgi script. You can find
277
+ sample config-files in active/www/app/httpd_config/. For instance,
277
278
active/www/app/httpd_config/nodedb_funkfeuer_at__443.config contains::
278
279
279
280
config_path = "~/fcgi/nodedb_funkfeuer_at__443.config"
@@ -289,66 +290,108 @@ Please note, the lines in the file must not contain leading whitespace.
289
290
290
291
Create a config::
291
292
292
- ### Create a fcgi script and config for Apache
293
- $ cp active/www/app/httpd_config/ffw_gg32_com__443.config deploy.config
294
- $ vi deploy.config
295
- ### edit the config to your needs
296
- $ python active/www/app/deploy.py fcgi_config \
297
- -HTTP_Config <your-config> -apache2_4 -input_encoding=utf-8
293
+ $ cp active/www/app/httpd_config/nodedb_funkfeuer_at__443__nginx.config \
294
+ deploy.config
295
+
296
+ $ vi deploy.config
297
+ ### edit the config to your needs
298
+ ### No leading spaces are allowed
299
+
300
+ $ mkdir uwsgi
301
+ $ python active/www/app/deploy.py uwsgi_config -apply_to_version active \
302
+ -HTTP_Config deploy.config
303
+
304
+ You can use the created webserver configuration as is, or modify it
305
+ manually or by modifiying the template.
298
306
299
307
Finally we create a database and populate it with data::
300
308
301
- ### Create a database
302
- $ python active /www/app/deploy.py app create -apply_to_version active
309
+ ### Byte compile python files
310
+ $ python passive /www/app/deploy.py pycompile -apply_to_version active
303
311
304
- ### Put some data into the database
312
+ ### Compile translations
313
+ $ python passive/www/app/deploy.py babel compile -apply_to_version active
305
314
306
- Log out user `ffw `
315
+ ### Create a database
316
+ $ python active/www/app/deploy.py app create -apply_to_version active
307
317
308
- You can use the created Apache configuration as is, or modify it
309
- manually or by modifiying the template.
318
+ ### Make sure the application cache is setup correctly
319
+ $ python active/www/app/deploy.py app setup_cache \
320
+ -apply_to_version active -verbose
321
+
322
+ ### Put some data into the database, e.g., by running a converter from
323
+ ### another database
324
+
325
+ ### Logout
326
+ $ exit
327
+
328
+ For Debian, the nginx configuration should be placed into
329
+ ``/etc/nginx/sites-available/ `` and linked to from
330
+ ``/etc/nginx/sites-enabled/ ``::
331
+
332
+ # cp /srv/ffw${pv}/uwsgi/<your-config-name>.conf /etc/nginx/sites-available/
333
+ # ( cd /etc/nginx/sites-enabled \
334
+ ; echo ln -s ../sites-available/<your-config-name>.conf
335
+ )
336
+
337
+ For Debian, the uwsgi configuration should be placed into
338
+ ``/etc/uwsgi/apps-available `` and linked to from
339
+ ``/etc/uwsgi/apps-enabled ``::
340
+
341
+ # cp /srv/ffw${pv}/uwsgi/<your-config-name>.ini \
342
+ /etc/uwsgi/apps-available/
343
+ # ( cd /etc/uwsgi/apps-enabled/ \
344
+ ; ln -s ../apps-available/<your-config-name>.ini
345
+ )
310
346
311
- For Debian, the apache configuration should be placed into
312
- ``/etc/apache2/sites-available/ ``, e.g., into the file
313
- ``nodedb2.example.com ``, and enabled. You probably will have to disable
314
- the default site installed. We used the following commands — we
315
- also enable some needed modules::
347
+ To test if the uwsgi configuration is correct, run the following command
348
+ and check for errors and the use of the right python interpreter::
316
349
317
- $ a2ensite nodedb2.example.com
318
- $ a2dissite default
319
- $ a2enmod expires
320
- $ a2enmod fcgid
321
- $ /etc/init.d/apache2 restart
350
+ # uwsgi --ini /etc/uwsgi/apps-enabled/<your-config-name>.ini
322
351
323
- For https sites, you'll also need the modules ::
352
+ If that looks good, restart uwsgi and nginx ::
324
353
325
- $ a2enmod rewrite
326
- $ a2enmod ssl
354
+ # /etc/init.d/uwsgi restart ; /etc/init.d/nginx restart
355
+
356
+ How to upgrade the installation
357
+ --------------------------------
327
358
328
359
Whenever we need to upgrade the installation, we can update the passive
329
360
configuration, set up everything, migrate the data from the active to
330
361
the passive configuration, and if everything went OK, enable it by
331
362
exchanging the symbolic links to the active and passive configuration::
332
363
333
- ### Test deployment script and generate some needed files
334
- ### Update source code
335
- $ python passive/www/app/deploy.py update
364
+ $ export pv='3' ### or '' if you use Python-2
365
+ $ alias python="python${pv}"
366
+ $ export PYTHONPATH=~/ passive/cndb:~/passive/tapyr
336
367
337
- ### Byte compile python files
338
- $ python passive/www/app/deploy.py pycompile
368
+ ### Update source code
369
+ $ python passive/www/app/deploy.py update
339
370
340
- ### Compile translations
341
- $ python passive/www/app/deploy.py babel compile
371
+ ### Byte compile python files
372
+ $ python passive/www/app/deploy.py pycompile
342
373
343
- ### Migrate database from active to passive
344
- $ python passive/www/app/deploy.py migrate -Active -Passive -verbose
374
+ ### Compile translations
375
+ $ python passive/www/app/deploy.py babel compile
345
376
346
- ### Setup app cache
347
- $ python passive/www/app/deploy.py setup_cache
377
+ ### Migrate database from active to passive
378
+ $ python passive/www/app/deploy.py migrate -Active -Passive -verbose
379
+
380
+ ### Optionally, test if database is still looking good
381
+ $ python passive/www/app/Command.py shell
382
+ ### Use queries in interactive Python shell, like::
383
+ >>> scope.MOM.Id_Entity.count
384
+ >>> scope.CNDB.Node.instance ("some-important-name's-name")
385
+ >>> scope.Auth.Account.query (Q.superuser).all ()
386
+
387
+ ### Setup app cache
388
+ $ python passive/www/app/deploy.py setup_cache
348
389
349
390
### Switch active and passive branches
350
391
$ python passive/www/app/deploy.py switch
351
- $ sudo /etc/init.d/apache2 restart
392
+
393
+ $ sudo /etc/init.d/uwsgi restart
394
+ $ sudo /etc/init.d/nginx restart
352
395
353
396
Contact
354
397
-------
0 commit comments