File: jobqueue.wsgi

package info (click to toggle)
python-bumps 1.0.3-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,200 kB
  • sloc: python: 24,517; xml: 493; ansic: 373; makefile: 211; javascript: 99; sh: 94
file content (52 lines) | stat: -rw-r--r-- 1,574 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"""
Install application into a mod_wsgi stack.

To be sure there is no cross-talk between installed packages, you will
want to create a blank virtualenv to run mod_wsgi and a virtualenv for
each application you are running on the server.

To create the blank environment::

    virtualenv --no-site-packages /usr/local/pythonenv/clean

To configure WSGI, edit /etc/apache2/mods-available/wsgi.conf, setting::

    WSGIPythonHome /usr/local/pythonenv/clean

Then create a bumps user account with its private virtualenv::

    virtualenv --no-site-packages ~/bumps

You can now populate the virtualenv with the required packages::

    cd ~/bumps
    # Use system install for binary packages
    ln -s /usr/share/pyshared/numpy lib/python2.6/site-packages
    ln -s /usr/share/pyshared/matplotlib lib/python2.6/site-packages
    ln -s /usr/share/pyshared/pytz lib/python2.6/site-packages
    ln -s /usr/share/pyshared/scipy lib/python2.6/site-packages
    # Install the less common packages by hand
    bin/pip install flask
    bin/pip install ...
"""

import os

# === Configure virtual environment ===
import site

PYROOT = os.path.abspath(os.path.expanduser("~/bumps"))
sitepackages = "lib/python%d.%d/site-packages" % sys.version_info[0:2]
site.addsitedir(PYROOT + sitepackages)

# === Configure resource locations ===
import jobqueue.server

jobqueue.server.configure(
    jobstore="~/.bumps/server/%s",
    jobkey="~/.bumps/key",
    jobdb="sqlite://" + os.path.abspath(os.path.expanduser("~/.bumps/db")),
    scheduler="dispatch",
)

application = jobqueue.server.app