结构任务的集合
dploi-fabric的Python项目详细描述
这是一组可重用的fabric任务。它使用新型的任务系统 织物的>;=1.2
用法
Add ^{tt1}$ to your buildout environment (preferably in ^{tt2}$, the servers have no use for it).
Create a ^{tt3}$ as normal.
Pick and choose the modules and import them in the ^{tt3}$, e.g.:
from fabric.decorators import task from dploi_fabric.db import pg # if project uses mysql, import "mysql" instead from dploi_fabric import supervisor, nginx from dploi_fabric import git, utils, buildout, south, django_utils, project from dploi_fabric.conf import load_settings @task def dev(): load_settings('dev') @task def stage(): load_settings('stage') @task def live(): load_settings('live') @task def deploy(): pg.dump.run() git.update() buildout.run() south.migrate.run() django_utils.collectstatic() supervisor.restart() supervisor.status() nginx.update_config_file()in the project root, create a file ^{tt5}$ following this template:
project_name = 'awesome_new_website' settings = { 'dev': { 'hosts': ['yourserver.com'], 'autostart': True, 'path': '/home/awesome_new_website-dev/app/', 'user': 'awesome_new_website-dev', 'buildout_cfg': 'server_dev.cfg', 'repo': 'git@github.com:youruser/awesome_new_website.git', 'branch': 'master', 'backup_dir': '/home/awesome_new_website-dev/tmp/', # Used for mysql/psql dumps 'db_name': 'awesome_new_website-dev', 'db_username': 'awesome_new_website-dev', 'domains': ['sitename-dev.agency.com', 'www.sitename.com'], 'domains_redirect': [ {'domain': 'sitename.com', 'destination_domain': 'www.sitename.com'}, ], 'ssl': True, 'ssl_key_path': '../config/ssl.key', # This must be uploaded manually, possibly by a task in the future 'ssl_cert_path': '../config/ssl.crt', # This must be uploaded manually, possibly by a task in the future 'basic_auth': False, 'basic_auth_path': '../config/htpasswd', # This must be uploaded manually, possibly by a task in the future }, }add settings for stage/live as needed.
call ^{tt6}$ for a list of commands
注意
使用这些任务时,必须修饰所有特定于项目的任务 使用fabric.api中的@task装饰符。
配置文件(config.ini)
记住添加config.ini,例如:
[static]
/media/ = py_src/project/media/
和/或
[static]
/static/ = %(static_files)s
芹菜
[celery]部分有一些特殊的配置参数:
- ^{tt10}$ (default: empty): set the celery version. Other the value ^{tt11}$ is recognized and triggers the usage of the ^{tt12}$ command instead of the django-celery based ^{tt13}$.
- ^{tt14}$ (default: ^{tt15}$): the module that contains the ^{tt16}$ (see the celery documentation)
其他选项
[checkout]
tool = buildout (default)
tool = virtualenv
[celery] (if the section is present, celery is enabled)
[django]
base = .
base = project/
base = py_src/project (doesnt work with buildout yet, as it would try to access py_src/project/bin/django)
append_settings = true
append_settings = false
[static]
(see above)
/url-path/ = rel-path-filesystem/
[sendfile] /protected/media/ = ../upload/