from fabric.api import *

env.path = '/var/praekelt/ummeli'

def qa():
    env.supervisord_file = 'supervisord.staging.conf'
    env.hosts = ['ubuntu@cloud.praekeltfoundation.org']

def production():
    env.supervisord_file = 'supervisord.production.conf'
    env.hosts = ['ubuntu@app1.praekeltfoundation.org']

def push():
    with cd(env.path):
        run('git pull')

def static():
    with cd(env.path):
        run('ve/bin/python %(path)s/ummeli/manage.py collectstatic --noinput' % env)


def deploy():
    with cd(env.path):
        run('git pull')
        run('kill -HUP `cat tmp/pids/gunicorn*.pid`')
        run('supervisorctl -c config/%(supervisord_file)s restart celery' % env)

def reload():
    with cd(env.path):
        run('source ve/bin/activate && kill -HUP `cat tmp/pids/*gunicorn*.pid`')

def restart(app='all'):
    env.app = app
    with cd(env.path):
        run('supervisorctl -c config/%(supervisord_file)s restart %(app)s' % env)

@@ -68,62 +68,8 @@
 ():%0A
-    env.supervisord_file = 'supervisord.staging.conf'%0A
     
@@ -143,65 +143,8 @@
 ():%0A
-    env.supervisord_file = 'supervisord.production.conf'%0A
     
@@ -477,24 +477,26 @@
 mp/pids/
+u_
 gunicorn
 *.pid%60')
@@ -479,32 +479,33 @@
 /pids/u_gunicorn
+_
 *.pid%60')%0A       
@@ -516,32 +516,11 @@
 ('su
-pervisorctl -c config/%25(
+do 
 supe
@@ -521,32 +521,27 @@
 o supervisor
-d_file)s
+ctl
  restart cel
@@ -537,16 +537,25 @@
 restart 
+ummeli:u_
 celery' 
@@ -616,34 +616,32 @@
 un('
-source ve/bin/activate && 
+git pull')%0A        run('
 kill
@@ -664,17 +664,18 @@
 ids/
-*
+u_
 gunicorn
 *.pi
@@ -670,16 +670,17 @@
 gunicorn
+_
 *.pid%60')
@@ -702,11 +702,8 @@
 pp='
-all
 '):%0A
@@ -762,32 +762,11 @@
 ('su
-pervisorctl -c config/%25(
+do 
 supe
@@ -775,16 +775,11 @@
 isor
-d_file)s
+ctl
  res
@@ -783,16 +783,23 @@
 restart 
+ummeli:
 %25(app)s'

update fabfile