Table Of Contents

Previous topic

Configuration

Next topic

Modules

This Page

Templates

Template in makesite - sctructure of files and folders. It will be copied when makesite install project.

Template syntax

In template files (with extention .tmpl), you can use simple syntax.

listen      {{ port }};
server_name {{ domain }};
access_log  {{ deploy_dir }}/logs/nginx_access.log;
error_log   {{ deploy_dir }}/logs/nginx_error.log;

Context for templates will be created from config files and command line options. In target files .tmpl will be removed.

Template specific files

Standart structure of makesite template:

template-name
    deploy -- configuration files
        ...
        file1.conf.tmpl -- file will be rendered with template engine
        file2.conf -- file will be copied as is
    service -- service install, remove, update files
    static -- static files
    ...
    [ makesite.ini ] -- custom template config (for default values)
    [ .makesite ] -- separated list of required templates (them will be installed before)

Celery3

Template celery3 has controled celery process with supervisor.

Requirements

Installed Supervisor.

Variables

celery_params

Define params for run celery (celery $celery_params)

Default: worker -A celery.celery -B -l info

celery_svconf

Define path for make link on generated supervisor config

Default: /etc/supervisor/conf.d/%(project)s.%(safe_branch)s.celery

Install operation

Copy link on generated supervisor.conf to supervisor directory. Update supervisor loaded programs.

Update operation

Restart the supervisor celery program.

Remove operation

Remove link on celery supervisor conf. Restart supervisor.


Virtualenv

Template has created virtualenv and watching requirements.txt for changes and updates.

Requirements

Installed pip and virtualenv python packages

Variables

virtualenv_dir

Define directory for create virtualenv

Default: %(deploy_dir)s/.virtualenv

pip_projectfile

Define path to requirements.txt file. In project source by default.

Default: %(deploy_dir)s/source/requirements.txt

pip_options

Define command line options for run PIP

Default: -IM -download-cache=/tmp/.pip-cache

Install operation

Create virtualenv in virtualenv_dir. Install requirements from pip_projectfile.

Update operation

Update requirements from pip_projectfile if it changes.


DB-Mysql

db-mysql — Create project role and database in mysql if it not exists.

Requirements

Installed mysql

Variables

mysqluser

MySQL user has rights for create DB

Default: root

mysqlpassword

Password for { mysqluser }

Default: root

mysqlhost

Host of mysql DB

Default: localhost

mysqlport

Port of mysql DB

Default: 3306

dbname

Name of project database

Default: { project }_master

dbuser

Owner name of project database

Default: { project }

dbpassword

Password for { db_user }

Default: { project }

Install operation

Create role { dbuser } and database { dbname } if it not exists.


DB-Postgres

db-postgres — Create project role and database in postgres if it not exists.

Requirements

Installed psql client.

Variables

pguser

PG user has rights for create DB

Default: postgres

pgpassword

Password for { pguser }

Default: postgres

pghost

Host of postgres DB

Default: localhost

pgport

Port of postgres DB

Default: 5432

dbname

Name of project database

Default: { project }_master

dbuser

Owner name of project database

Default: { project }

dbpassword

Password for { dbuser }

Default: { project }

Install operation

Create role { dbuser } and database { dbname } if it not exists.


List

base, src-dir, src-git, db-postgres, django, tornado, memcached, cron, nginx, supervisor, uwsgi, zeta, compass, html

base

Auto added to all makesite projects. Load project source and create base structure. base source

  1. INSTALL, UPDATE

    Change deploy folder owner and group to makesite option <site_user>:<site_group>, default is www-data

    Make service files is executable.

src-dir

Load code in project from path.

This template will be auto added in project if deploy source it is local path. src-dir source

  1. UPDATE

    Copy project source from source dir to deploy source dir

    Copy static dir from deploy source static dir to deploy static dir

src-git

Load code in project from git source.

This template will be auto added in project if deploy source it is git path. src-git source

  1. UPDATE

    Update git project source dir.

db-postgres

Auto create user and db for project if it not exist. db-postgres source .. note

Require <pguser>, <pghost>, <pgpassword>, <pgport> variables in configs with admin rights
  1. INSTALL

    Create postgres user <dbuser> if not exists, default is <project> with password <dbpassword> default is <project>

    Create postgres db <dbname> default <project>_master.

django

Deploy and update django projects. django source

Note

Now it working in last django version from trunk collectstatic Required manage.py in project root.

INCLUDED memcached, virtualenv, cron

  1. INSTALL

    Run manage.py syncdb

  2. UPDATE

    Run manage.py migrate Run manage.py collectstatic

tornado

Deploy and update tornado projects. Contains nginx and supervisor configs. tornado source

Note

Required app.py in project root with tornado application app.py must parse –port option

INCLUDED virtualenv, cron, memcached, supervisor, nginx

memcached

Install python-memcached and flush memcached cache on updates. memcached source

default options

memcached_host=localhost
memcached_port=11211
  1. INSTALL, UPDATE

    Install python-memcached if not exist and flush memcached cache

virtualenv

Create virtual env for project and update pip requirements.

default options ::
virtualenvdir={{ deploy_dir }}/.virtualenv pip_projectfile={{ deploy_dir }}/source/requirements.txt
  1. INSTALL

    Install virtualenv in it not exists. Create virtual env and update pip requirements

  2. UPDATE

    Update pip requirements if it needed

cron

Add project cron tasks in crond. cron source

Note

Default <cron_projectfile> is crontab in project root. File in cron format. Commands from this file will be runned from <site_user> relative project root and with enabled project virtualenv

default options

cron_projectfile={{ project_sourcedir }}/crontab
cron_outputfile=/etc/cron.d/{{ project }}-{{ branch }}
  1. INSTALL, UPDATE

    Parse project crontab file and add it to cron.

  2. REMOVE

    Remove project cron tasks from cron.

nginx

nginx support

default options

nginx_target_confpath=/etc/nginx/sites-enabled/{{ project }}.{{ branch }}.conf
nginx_source_confpath=<deploy_dir>/deploy/nginx.conf
  1. INSTALL

    Install nginx if not exist Create link <nginx_confpath> to deploy nginx.conf ( its make other templates ex django or tornado ) Restart nginx

  2. REMOVE

    Remove link <nginx_confpath> Restart nginx

supervisor

Supervisor_ support.

default options ::
supervisor_target_confpath=/etc/supervisor/conf.d/{{ project }}.{{ branch }}.conf supervisor_source_confpath=<deploy_dir>/deploy/supervisor.conf supervisor_taskname=<project>.<branch>
  1. INSTALL

    Install supervisor if not exists Create link to <supervisor_confpath> its make another templates ex: django, tornado Reread supervisor configs

  2. UPDATE

    Restart supervisor project task

  3. REMOVE

    Remove link <supervisor_confpath> Reread supervisor configs

uwsgi

uwsgi support. Contains nginx and supervisor configs. uwsgi source

Note

uwsgi template waiting file wsgi.py in project source root with defined wsgi application

default options ::
uwsgi_source_confpath=<deploy_dir>/deploy/uwsgi.xml
zeta

zeta support. Packing project static files. zeta source

  1. INSTALL, UPDATE

    Packing js, css, scss files from deploy static dir.

compass
compass support. compass source
html
static html site. Contains nginx config. Serve files from project staticdir.