-
Notifications
You must be signed in to change notification settings - Fork 0
/
fabfile.py
54 lines (37 loc) · 1.15 KB
/
fabfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from __future__ import with_statement
import os
from fabric.api import *
from fabric.contrib.project import rsync_project
# sample 'context' configuration
# def example():
# env.hosts = ['example.com']
# env.path = '/home/services/www/example' # without trailing slash
# env.user = 'user'
def setup():
run('mkdir -p %s && cd %s && virtualenv $(pwd)' % (env.path, env.path))
def push():
"""Sync new development code on device"""
rsync_project(
remote_dir=env.path,
local_dir=".",
# delete=True,
exclude=[".git*", ".svn*", "*.pyc", "*.pyo"])
run("chown :www-data -R %s/" % env.path)
run("chmod g+rw -R %s/%s/db" % (env.path, 'project'))
def requirements():
"""Install the required packages from the requirements file using pip"""
run('cd %s && pip install -E $(pwd) -r requirements.txt' % env.path)
def restart():
"""Restart apache"""
sudo("/etc/init.d/apache2 restart")
def setup_and_deploy():
"""Full deploy: push and start"""
setup()
push()
requirements()
restart()
def deploy():
"""Full deploy: push and start"""
push()
requirements()
restart()