1. José L. Patiño Andrés
  2. codelinker

Overview

Project layout

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.

Installation

New installations (for development or production) should follow the steps below.

  1. Navigate to the location where you want to place your project.

  2. Get the code:

    $ git clone ssh://git@bitbucket.org/maykinmedia/codelinker.git
    $ cd codelinker
    
  3. 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>
    
  4. 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
    

Developers

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.

Enable SASS/Compass:

$ compass watch

For more information on SASS and Compass, see: http://compass-style.org/

Get all Javascript libraries:

$ 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.

Update installation

When updating an existing installation:

  1. Activate the virtual environment:

    $ cd codelinker
    $ source env/bin/activate
    
  2. Update the code and libraries:

    $ git pull
    $ pip install -r requirements/<production|staging|test|development>.txt
    
  3. 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