deploy-custom.rst 2.08 KB
Newer Older
Nicolas Joyard's avatar
Nicolas Joyard committed
1
2
3
4
5
6
7
8
Deployment on a custom machine
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Prerequisites
=============

You will need the following:

9
* A clone of the git repository at ``https://git.laquadrature.net/memopol/memopol.git``
10
* A dedicated python virtualenv
Nicolas Joyard's avatar
Nicolas Joyard committed
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
* a PostgreSQL>=9.2 database (not necessarily on the same machine)
* a WSGI-capable web server

Setup environment
=================

Set the following environment variables::

    DJANGO_SETTINGS_MODULE=memopol.settings

Customize settings
==================

Create a copy of the example local settings file::

Jamesie Pic's avatar
Jamesie Pic committed
26
    $ cp src/memopol/local_settings.py.example src/memopol/local_settings.py
Nicolas Joyard's avatar
Nicolas Joyard committed
27

Jamesie Pic's avatar
Jamesie Pic committed
28
Edit ``src/memopol/local_settings.py`` to set directories, database settings and
Nicolas Joyard's avatar
Nicolas Joyard committed
29
30
31
32
allowed hosts.  Setup your WSGI server to serve:

* Static files from the directory specified in the ``PUBLIC_DIR`` setting to the
  ``/static`` URL
Jamesie Pic's avatar
Jamesie Pic committed
33
* The ``src/memopol/wsgi.py`` WSGI application
Nicolas Joyard's avatar
Nicolas Joyard committed
34
35
36
37

Initial memopol setup
=====================

38
39
From the repository root, install python dependencies (you may want to do that
in a virtualenv)::
40

41
    $ pip install -U pip setuptools
42
43
    $ pip install -Ue .

Nicolas Joyard's avatar
Nicolas Joyard committed
44
45
Install client libraries::

Jamesie Pic's avatar
Jamesie Pic committed
46
    $ src/memopol/bin/install_client_deps.sh
Nicolas Joyard's avatar
Nicolas Joyard committed
47
48
49

Setup the database schema::

50
    $ memopol migrate --noinput
Nicolas Joyard's avatar
Nicolas Joyard committed
51
52
53

Collect static files::

54
    $ memopol collectstatic --noinput
Nicolas Joyard's avatar
Nicolas Joyard committed
55
56
57
58
59
60
61
62
63

Memopol should be ready to go.

Updating
========

To update simply pull the repository and run setup commands again::

    $ git pull
64
    $ pip install -Ue .
65
66
67
    $ src/memopol/bin/install_client_deps.sh
    $ memopol migrate --noinput
    $ memopol collectstatic --noinput
Nicolas Joyard's avatar
Nicolas Joyard committed
68
69
70
71
72
73
74
75
76

Data provisionning
==================

Set up two cron jobs:

* One to update data from parliaments, that runs ``bin/update_all``.  This
  script takes quite some time to run, so you should schedule it once every
  night for example
77
* One to refresh scores,  that runs ``memopol refresh_scores``.  This one
Nicolas Joyard's avatar
Nicolas Joyard committed
78
79
80
81
82
83
84
  runs quite quickly (a few seconds), you may want to run it after the update
  job has completed (but you can run it more often).

Ensure that cron jobs get the same environment as the application.


Continue to :doc:`administration`.