- Adds management command to make configs for your project. Now it can generate config for lighttpd, logrotate, monit and deploy scripts.
- Automatically recognizes media directories in 3-party applications and takes them into account.
- Put
config
to yourINSTALLED_APPS
. Set domain names for your project :
CONFIG_SITES = ['www.project-name.com', ]
Domains for which you want redirects to your site :
CONFIG_REDIRECTS = ['project-name.com', ]
Serving static files
Set path to media for unusual 3-party application :
CONFIG_APP_MEDIA = { 'application-name': [ ('media-root', 'media-url', ), ] }
Media folders with same name as application modulde will be added automatically. For example, in
tinymce
module media files :tinymce/ media/ tinymce/ js/tinymce.js css/style.css
will be available at url:
/media/tinymce/js/tinymce.js /media/tinymce/css/style.js
Stop! Aren't Django staticfiles do that?
Yes, they do. But django-servre-config is older than staticfiles and does same job. This feature will is deprecated and will not be supported since 0.2.x release. We recommend to use Django contrib application django.contrib.statifiles
. Read below about how to do it.
If you use
django-server-config
for serving static media, add following code to the urls.py for serve static files in debug mode. Add it BEFOREdjango.views.static.serve
:if settings.DEBUG: urlpatterns += patterns('', (r'^', include('config.urls')))
If you are using zc.buildout, you can add to your parts
make-config
to make config files automaticaly:[make-config] recipe = iw.recipe.cmd on_install = true on_update = true cmds = sudo rm -f bin/init.d bin/lighttpd bin/logrotate bin/monit bin/*.py bin/django make_config init.d > bin/init.d bin/django make_config lighttpd > bin/lighttpd bin/django make_config logrotate > bin/logrotate bin/django make_config monit > bin/monit # Enable backups with duply & duplicity (http://duplicity.nongnu.org) bin/django make_config duply_conf > bin/duply_conf bin/django make_config duply_pre > bin/duply_pre bin/django make_config duply_post > bin/duply_post bin/django make_config duply_exclude > bin/duply_exclude # Collect static automaticaly sudo rm -Rf static bin/django collectstatic -l ---noinput sudo chown www-data:www-data -R static bin/django make_config install.py > bin/install.py bin/django make_config uninstall.py > bin/uninstall.py bin/django make_config enable.py > bin/enable.py bin/django make_config disable.py > bin/disable.py sudo chown root:root bin/* sudo chmod ug=rw,o=r bin/* sudo chmod ug=rwx,o=rx bin/init.d bin/django bin/buildout echo Configs were saved to "bin/"
Without bulidout
If you are not using zc.buildlout, you can add to repository shell script with commands above, it will give same effect.
Since 0.1.1 server-config supports django.contrib.staticfiles
and staticfiles
apps. If one of them present in INSTALLED_APPS
, config for webserver will be generated with appropriate rewrite rule.
If staticfiles
is used there is no need to include config.urls
in urlconf.py
. On the other hand, probably you will want to include staticfiles_urlpatterns()
from staticfiles app (see: django documentation about it) :
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns += staticfiles_urlpatterns()
Django-server-config can automatically create backups configuration files. It supports duply (duplicity) configuration scheme. Duplicity is backup system written in python and using rsync algorithm and Duply is bash configuration wrapper for Duplicity.
Security Note
To start using backups you should specify path to main configuration file for duply. Django-server-config expects file in *.ini
format. This file can contains secret passwords, so file supposed to be located somewhere in /etc/duply/conf.ini
and belongs to root (superuser).
- BACKUP_DUPLY_CONFIG
Path to duply configuration file
- BACKUP_TEMP_DIR
Temp directory, where database backups will be located. Database dumps will be deleted from file system after each backup session. Default value:
'/var/backups/postgres'
Only PostgreSQL database backups are supported!
It is quite simple to configure duply. You can create duply initial config simply from command line::
duply <profile> create
Then look at ~/.duply/<profile>/conf and follow comments.
Moreover, you can use ours config template:
[duply]
GPG_PW='**********'
TARGET='s3+http://**********@com.mycompany.server/'
SOURCE='/'
MAX_AGE=1M
MAX_FULL_BACKUPS=5
MAX_FULLBKP_AGE=1W
VOLSIZE=50
DUPL_PARAMS="$DUPL_PARAMS --full-if-older-than $MAX_FULLBKP_AGE --volsize $VOLSIZE "
This template encrypts backups with GPG and uplaod to AmazonS3 bucket com.mycompany.server
.
Pay attention to the TAGET
option. Django-server-config will automatiocally add project_name to TARGET
. E.g. rendered config will contain value:
TARGET = s3+http://**********@com.mycompany.server/<myproject>
Consider trailing slash in *.ini
config, django-server-config adds only myproject
without slash.
- 0.1.0 - Initial commit
- 0.1.1 - Staticfiles support added
- 0.1.2 - Duply backups support
- 0.1.3 - Emergency lighttpd config fix (staticfiles didn't work), don't use v0.1.1!