Build Devilry¶
Devilry does not come pre-packaged. Instead, we deploy using buildout. There is several reasons for that:
- It is easier to maintain deployment through buildout.
- It is easier to customize Devilry when we do not have to force defaults on people. With the current method of deployment, admins can easily intergrate local devilry addons.
- The method we are using seems to work very well for the Plone CMS.
What this means for you is that you have to setup a very minimal buildout-config instead of downloading an archive and unzipping it.
Create a system user for Devilry¶
You should run Devilry as a non-privledged user. We suggest you name the user
something like devilryrunner
. Run all commands in this documentation as
this user unless stated otherwise.
Configure buildout¶
Create a directory that will be used to configure your Devilry build:
$ mkdir devilrybuild
Create a configuration file named buildout.cfg
in the directory. Add the
following to the configuration file:
[buildout]
extends = https://raw.github.com/devilry/devilry-deploy/REVISION/buildout/buildout-base.cfg
Replace REVISION
(in the extends url) with the Devilry version you want to
use (E.g.: v1.2.1
). See the tag listing on github for a list of all releases,
and refer to The releasenotes listing
for the information about each release.
Install required system packages¶
Initialize the buildout¶
CD to the directory and run the following commands to download Devilry and all dependencies into a Python virtualenv. The end result is a selfcontained devilry build that only depends on the availability of a compatible Python interpreter to run. The virtualenv is not affected by other Python packages installed globally:
$ cd devilrybuild/
$ mkdir -p buildoutcache/dlcache
$ virtualenv --no-site-packages .
$ bin/easy_install zc.buildout
$ bin/buildout "buildout:parts=download-devilryrepo" && bin/buildout
Configure Devilry¶
To configure Devilry, you need to create a Python module containing a
config-file named devilry_prod_settings.py
. First create a directory for
your Devilry configurations:
$ mkdir /etc/devilry
turn the directory into a Python module:
$ touch /etc/devilry/__init__.py
and add your own devilry_prod_settings.py
to the directory. This is a good starting point:
# Import the default settings from devilry
from devilry_settings.default_settings import *
#################################################################################
# Configure the database
#################################################################################
DATABASES = {}
DATABASES["default"] = {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'djangodb',
'USER': 'djangouser',
'PASSWORD': 'supersecret',
'HOST': 'localhost',
}
##################################################################################
# Make Devilry speak in typical university terms (semester instead of period, ...)
##################################################################################
INSTALLED_APPS += ['devilry_university_translations']
DEVILRY_JAVASCRIPT_LOCALE_OVERRIDE_APPS = ('devilry_university_translations',)
#################################################################################
# Email settings
#################################################################################
#: Default from email - students receive emails from this address when they make deliveries
DEVILRY_EMAIL_DEFAULT_FROM = 'devilry-support@example.com'
#: The URL that is used to link back to devilry from emails
DEVILRY_SCHEME_AND_DOMAIN = 'https://devilry.example.com'
#: Configure an email backend (see the docs for more info)
#EMAIL_BACKEND = 'djcelery_email.backends.CeleryEmailBackend'
#CELERY_EMAIL_HOST_USER = ''
#CELERY_EMAIL_HOST_PASSWORD = ''
#CELERY_EMAIL_PORT = 25
#CELERY_EMAIL_USE_TLS = False
##################################################################################
# Other settings
##################################################################################
#: Where should Devilry store your files
DEVILRY_FSHIERDELIVERYSTORE_ROOT = '/devilry-filestorage'
#: Randomize this, and keep it secret
SECRET_KEY = '+g$%**q(w78xqa_2)(_+%v8d)he-b_^@d*pqhq!#2p*a7*9e9h'
#: Turn this on if you need to debug Devilry
DEBUG = False
EXTJS4_DEBUG = DEBUG
#: Change this to the name of the system which you fetch data into Devilry from.
DEVILRY_SYNCSYSTEM = 'The Devilry demo syncsystem'
#: Url where users are directed when they do not have the permissions they believe they should have.
DEVILRY_LACKING_PERMISSIONS_URL = None
#: Url where users are directed when they want to know what to do if their personal info in Devilry is wrong.
DEVILRY_WRONG_USERINFO_URL = None
#: Deadline handling method:
#:
#: 0: Soft deadlines
#: 1: Hard deadlines
DEFAULT_DEADLINE_HANDLING_METHOD = 0
The config-file can contain any official Django settings, and Devilry provides some extra settings that should be useful:
- Django email backends
- Django settings
- Devilry settings (scroll down to the Default for settings defined by Devilry section).
- django-celery-email is an addon that sends email in a background queue. The addon is installed by devilry-deploy by default, and is highly recommended (see https://github.com/devilry/devilry-django/issues/477).
Note
You can put devilry_prod_settings.py
in another directory. You just have to set:
[buildout]
...
configdir = /etc/devilry
in your buildout.cfg
and re-run bin/buildout
.
Create the database¶
When you have configured a database in devilry_prod_settings.py
, you
can use the following command to create your database:
$ cd /path/to/devilrybuild
$ bin/django.py syncdb
The script will ask you to create a superuser. Choose a strong password - this user will have complete access to everything in Devilry.
Install RabbitMQ¶
Follow the guides at their website: http://www.rabbitmq.com/download.html
Refer to the RabbitMQ docs for regular configuration, like logging and database-file location. The defaults are usable.
Configure RabbitMQ for Devilry¶
Start the RabbitMQ server.
RabbitMQ creates a default admin user named guest
with password guest
.
Remove the guest user, and create a new admin user (use another password than
secret
):
$ rabbitmqctl delete_user guest
$ rabbitmqctl add_user admin secret
$ rabbitmqctl set_user_tags admin administrator
$ rabbitmqctl set_permissions admin ".*" ".*" ".*"
Setup a vhost for Devilry with a username and password (use another password
than secret
):
$ rabbitmqctl add_user devilry secret
$ rabbitmqctl add_vhost devilryhost
$ rabbitmqctl set_permissions -p devilryhost devilry ".*" ".*" ".*"
Add RabbitMQ settings to Devilry¶
Add the following to /etc/devilry_prod_settings.py
(change secret
to
match your password):
$ BROKER_URL = 'amqp://devilry:secret@localhost:5672/devilryhost'
Test the install¶
See Debug problems.
Setup Devilry for production¶
Collect all static files in the static/
-subdirectory:
$ bin/django.py collectstatic
Make sure all services work as excpected¶
All Devilry services is controlled to Supervisord. This does not include your database or webserver.
To run supervisord in the foreground for testing/debugging, enable DEBUG-mode (see Debug problems), and run:
$ bin/supervisord -n
Make sure you disable DEBUG-mode afterwards.
Run Supervisord for production¶
To run supervisord in the background with a PID, run:
$ bin/supervisord
See Configure supervisord (logging, pidfile, ...) to see and configure where the PID-file is written, and for an init-script example.
Warning
Do NOT run supervisord as root. Run it as an unpriviledged used, preferably
a user that is only used for Devilry. Use the supervisord-user
, as shown
in Configure supervisord (logging, pidfile, ...), to define a user if running supervisord as
root.
Configure your webserver¶
You need to configure your webserver to act as a reverse proxy for all URLS
except for the /static/
-url. The proxy should forward requests to the
Devilry WSGI server (gunicorn). Gunicorn runs on 127.0.0.0:8002
.
The webserver should use SSL.