forked from okfde/offenesparlament.de
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fabfile.py
42 lines (32 loc) · 1.46 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
from fabric.api import *
env.hosts = ['norton.pudo.org']
deploy_dir = '/var/www/offenesparlament.de/'
backup_dir = '/var/www/opendatalabs.org/backup'
remote_user = 'fl'
pip_cmd = deploy_dir + 'bin/pip '
def deploy():
run('mkdir -p ' + backup_dir)
run('pg_dump -f ' + backup_dir + '/opa_web-`date +%Y%m%d`.sql opa_web')
with cd(deploy_dir + 'src/offenesparlament'):
run('git pull')
run('git reset --hard HEAD')
run(pip_cmd + 'install -r pip-requirements.txt')
sudo('supervisorctl reread')
sudo('supervisorctl restart offenesparlament')
run('curl -X PURGEDOMAIN http://offenesparlament.de')
def install():
sudo('rm -rf ' + deploy_dir)
sudo('mkdir -p ' + deploy_dir)
sudo('chown -R ' + remote_user + ' ' + deploy_dir)
put('deploy/*', deploy_dir)
sudo('mv ' + deploy_dir + 'nginx.conf /etc/nginx/sites-available/offenesparlament.de')
sudo('service nginx restart')
sudo('ln -sf /etc/nginx/sites-available/offenesparlament.de /etc/nginx/sites-enabled/offenesparlament.de')
sudo('ln -sf ' + deploy_dir + 'supervisor.conf /etc/supervisor/conf.d/offenesparlament.de.conf')
run('mkdir ' + deploy_dir + 'logs')
sudo('chown -R www-data.www-data ' + deploy_dir + 'logs')
run('virtualenv ' + deploy_dir)
run(pip_cmd + 'install gunicorn gevent')
run(pip_cmd + 'install -e [email protected]:pudo/offenesparlament.git#egg=offenesparlament')
deploy()
run(pip_cmd + 'install datafreeze')