forked from mgax/agripay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fabfile.py
68 lines (55 loc) · 2 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
from StringIO import StringIO
import tempfile
import json
from fabric.api import *
from fabric.contrib.files import exists
from path import path
env['use_ssh_config'] = True
SARGE_HOME = path('/var/local/agripay')
ES_KIT = ('https://github.com/downloads/elasticsearch/'
'elasticsearch/elasticsearch-0.19.9.tar.gz')
ES_ATTACH_SPEC = 'elasticsearch/elasticsearch-mapper-attachments/1.6.0'
AGRIPAY_VENV = SARGE_HOME / 'var' / 'agripay-venv'
AGRIPAY_CONFIG = {
'SENTRY_DSN': ('http://326f1cd02a1b474a9b973f5e2c74d76c'
':cc011e2b752945b6895938893a8fa14a'
'@sentry.gerty.grep.ro/3'),
'ES_HEAP_SIZE': '256m',
'AGRIPAY_VENV': AGRIPAY_VENV,
'PYTHONPATH': '.',
'DATABASE_PATH': SARGE_HOME / 'var' / 'db.sqlite',
'MAPSERV_BIN': '/usr/local/mapserver-6.0.3/mapserv',
}
env.update({
'host_string': 'gerty',
'agripay_python_bin': '/usr/local/Python-2.7.3/bin/python',
'sarge_home': SARGE_HOME,
'agripay_venv': AGRIPAY_VENV,
})
@task
def configure():
etc_app = env['sarge_home'] / 'etc' / 'app'
run('mkdir -p {etc_app}'.format(**locals()))
put(StringIO(json.dumps(AGRIPAY_CONFIG, indent=2)),
str(etc_app / 'config.json'))
@task
def virtualenv():
if not exists(env['agripay_venv']):
run("virtualenv '{agripay_venv}' "
"--distribute --no-site-packages "
"-p '{agripay_python_bin}'"
.format(**env))
put("requirements.txt", str(env['agripay_venv']))
run("{agripay_venv}/bin/pip install "
"-r {agripay_venv}/requirements.txt"
.format(**env))
@task
def deploy(app_name):
with cd(env['sarge_home']):
with tempfile.NamedTemporaryFile() as tmp_file:
local('git archive HEAD | gzip > {tmp}'
.format(tmp=tmp_file.name))
put(tmp_file.name, '_deploy.tgz'.format(**env))
run("{sarge_home}/bin/sarge deploy <(zcat _deploy.tgz) {app_name}"
.format(app_name=app_name, **env))
run('rm _deploy.tgz')