forked from PyAr/pyarweb
-
Notifications
You must be signed in to change notification settings - Fork 3
/
fabfile.py
42 lines (32 loc) · 1.12 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
from fabric.api import env, run, task
from fabric.context_managers import cd
from fabric.contrib.console import confirm
env.hosts = ['python.org.ar']
env.user = 'www-pyar'
env.project_path = '/home/www-pyar/pyarweb/pyarweb/'
env.venv_path = '/home/www-pyar/pyarweb/pyarweb_venv/'
env.pip_bin = '%sbin/pip' % (env.venv_path)
env.python_bin = '%sbin/python' % (env.venv_path)
env.gunicorn_bin = '%sbin/gunicorn' % (env.venv_path)
@task
def deploy():
"""Deploy de PyArweb en python.org.ar."""
git_pull()
if confirm("Install/upgrade requirements with pip?"):
install_requeriments()
django_command('collectstatic')
django_command('migrate')
restart()
@task
def restart():
"""Restart gunicorn sending HUP signal to his pid."""
run('kill -HUP $(cat /tmp/pyar_web.pid)')
def git_pull():
with cd(env.project_path):
run('git pull')
def django_command(command):
with cd(env.project_path):
run('%s manage.py %s --noinput' % (env.python_bin, command))
def install_requeriments():
with cd(env.project_path):
run('%s install --upgrade -r requirements.txt' % (env.pip_bin))