Deploy to a production siteΒΆ

Needs revision.

The server has two subdomains "lino" and "testlino". Each subdomain has its own project directory. Each project directory has a symbolic link env which points to its Python environment.

  • Create a new virtualenv:

    $ cd ~/pythonenvs
    $ virtualenv b

    Clone the code repositories and install them into the new environment:

    $ cd ~/pythonenvs/b
    $ mkdir repositories
    $ cd repositories
    $ git clone
    $ git clone
    $ git clone
    $ pip install -e lino
    $ pip install -e lino-cosi
    $ pip install -e lino-welfare

    Install the Python binding for MySQL:

    pip install MySQL-python
  • Check whether a snapshot exists

  • Compare the files:

    $ cd /usr/local/django/prod
    $ diff ../testing/

    Most differences are normal, but the new version might require changes. Normal differences:

  • Switch the project directories to their new environments:

    $ cd /usr/local/django/prod
    $ ls -ld env
    lrwxrwxrwx 1 lsaffre www-data 33 Sep 28 18:54 env -> /home/luc/pythonenvs/a
    $ rm env
    $ ln ~/pythonenvs/b env
    $ ls -ld env
    lrwxrwxrwx 1 lsaffre www-data 33 Sep 28 18:54 env -> /home/luc/pythonenvs/b

    Usually every project moves to the "next" environment.

  • Run collectstatic in the new environment:

    $ cd /usr/local/django/testing
    $ a
    $ python collectstatic
    You have requested to collect static files at the destination
    location as specified in your settings:
    This will overwrite existing files!
    Are you sure you want to do this?

    Note that we define the STATIC_ROOT in both project dirs as follows:

    STATIC_ROOT = SITE.project_dir.child('env', 'collectstatic').resolve()

    Note that project_dir is a Unipath object, and that the resolve method resolves symbolic links (transforms them to their "real" path).

  • Restore production data from snapshot:

    $ cd /usr/local/django/prod
    $ a
    $ python run snapshot/
  • Restart Apache

  • Log in and see whether everything seems okay.