The project layout was made in such a way that code is seperated from non-code files that you typically want to serve in another way (static and media files) or keep in a different location (like the virtual environment):
codelinker | +-- env -- Virtual environment files. | +-- src -- Container for one or more source directories. | | | +-- codelinker | | | +-- conf -- Django settings files. | | | +-- templates -- Project templates | | | +-- wsgi -- Default location for wsgi deployment scripts | | | +-- static -- Default location for project static files | | | +-- ... -- Project specific applications. | +-- static -- Default location for collected static files. | +-- media -- Default location for uploaded media files. | +-- log -- All log files generated by the project. | +-- doc -- Documentation source and generated files. | +-- requirements -- Project requirements for each type of installation.
New installations (for development or production) should follow the steps below.
Navigate to the location where you want to place your project.
Get the code:
$ git clone ssh://firstname.lastname@example.org/maykinmedia/codelinker.git $ cd codelinker
Bootstrap the virtual environment and install all required libraries. The boostrap.py script basically sets the proper Django settings file to be used:
$ python bootstrap.py <production|staging|test|development>
Activate your virtual environment and create the statics and database:
$ source env/bin/activate $ python src/manage.py collectstatic --link $ python src/manage.py migrate
Optionally, you can load demo data and extract demo media files:
$ python src/manage.py loaddata demo $ cd media $ tar -xzf demo.tgz
You can now run your installation and point your browser to the address given by this command:
$ python src/manage.py runserver
If you are making local, machine specific, changes, add them to src/codelinker/conf/settings_local.py. You can base this file on the example file included in the same directory.
$ compass watch
For more information on SASS and Compass, see: http://compass-style.org/
$ bower install
For more information on Node.js, see: http://nodejs.org/
Staging and production
Configure your webserver and/or WSGI handler. See: https://docs.djangoproject.com/en/dev/howto/deployment/
Note that your wsgi script in ``src/codelinker/wsgi.py already points to your staging|production settings.py file. This happens when bootstrapping your environment.
When updating an existing installation:
Activate the virtual environment:
$ cd codelinker $ source env/bin/activate
Update the code and libraries:
$ git pull $ pip install -r requirements/<production|staging|test|development>.txt
Update the statics and database:
$ python src/manage.py collectstatic --link $ python src/manage.py migrate
Custom management commands
Management commands are often run in a cronjob with stdout redirected to a log file.
Make sure to use the 'maven' management command, so use:
$ python src/manage.py maven my_custom_management_command >> log/my_command.log 2>&1
This ensures that uncaught exceptions end up in Sentry instead of being overlooked in the log files