Update common.txt
[oweals/karmaworld.git] / fabfile.py
index 8a748d6879b490e7ee707f17c75529a23fe078b0..22fcf5271d69d785e48d2bdbd95230f52c0fc463 100644 (file)
@@ -17,15 +17,17 @@ def here():
     """
     Connection information for the local machine
     """
+    def _custom_local(command):
+        prefixed_command = '/bin/bash -l -i -c "%s"' % command
+        return local(prefixed_command)
 
+    env.run = _custom_local
     # This is required for the same reason as above
-    env.proj_dir = os.getcwd()
-    env.proj_root = os.path.dirname(env.proj_dir)
+    env.proj_root = '/var/www/karmaworld'
     env.cd = lcd
     env.reqs = 'reqs/dev.txt'
-    env.confs = 'confs/stag/'
+    env.confs = 'confs/beta'
     env.branch = 'beta'
-    env.run = virtenv_exec
 
 
 
@@ -39,9 +41,8 @@ def prod():
     env.user = 'djkarma'
     env.hosts = ['karmanotes.org']
     env.proj_root = '/var/www/karmaworld'
-    env.proj_dir = '/var/www/karmaworld'
     env.reqs = 'reqs/prod.txt'
-    env.confs = 'confs/beta/'
+    env.confs = 'confs/prod/'
     env.branch = 'beta'
     env.run = virtenv_exec
     env.gunicorn_addr = '127.0.0.1:8000'
@@ -56,12 +57,10 @@ def beta():
     env.user = 'djkarma'
     env.hosts = ['beta.karmanotes.org']
     env.proj_root = '/var/www/karmaworld'
-    env.proj_dir = '/var/www/karmaworld'
-    env.reqs = 'reqs/beta.txt'
-    env.confs = 'confs/beta/'
+    env.reqs = 'reqs/prod.txt'
+    env.confs = 'confs/prod/'
     env.branch = 'beta'
     env.run = virtenv_exec
-    env.gunicorn_addr = '127.0.0.1:8000'
 
 ######## Run Commands in Virutal Environment
 def virtenv_exec(command):
@@ -69,7 +68,7 @@ def virtenv_exec(command):
        Execute command in Virtualenv
        """
 
-        with virtualenv('%s/%s' % (env.proj_dir, env.branch)):
+        with virtualenv('%s/%s' % (env.proj_root, env.branch)):
                 run('%s' % (command))
 
 ######## Sync database
@@ -79,17 +78,17 @@ def syncdb():
        Sync Database
        """
 
-       env.run('%s/manage.py syncdb --noinput --migrate' % env.proj_dir )
+       env.run('%s/manage.py syncdb --migrate' % env.proj_root )
 
 
 ####### Collect Static Files
 @task
 def collect_static():
        """
-       Collect static files (if AWS config. present, push to S3
+       Collect static files (if AWS config. present, push to S3)
        """
 
-       env.run('%s/manage.py collectstatic --noinput' % env.proj_dir ) 
+       env.run('%s/manage.py collectstatic --noinput' % env.proj_root )        
 
 ####### Run Dev Server
 @task
@@ -98,7 +97,7 @@ def dev_server():
        Runs the built-in django webserver
        """
 
-       env.run('%s/manage.py runserver' % env.proj_dir )       
+       env.run('%s/manage.py runserver' % env.proj_root)       
 
 ####### Create Virtual Environment
 @task
@@ -108,7 +107,7 @@ def make_virtualenv():
        """
 
        run('virtualenv %s/%s' % (env.proj_root, env.branch))
-       env.run('pip install -r %s/reqs/%s.txt' % (env.proj_dir, env.branch) )
+       env.run('pip install -r %s/reqs/%s.txt' % (env.proj_root, env.branch) )
 
 @task
 def start_supervisord():
@@ -203,5 +202,34 @@ def update_reqs():
 ####### Pull new code
 @task
 def update_code():
-       env.run('cd %s; git pull' % env.proj_dir)
+       env.run('cd %s; git pull' % env.proj_root )
+
+@task
+def backup():
+    """
+    Create backup using bup
+    """
+@task
+def first_deploy():
+    
+    """
+    Sets up and deploys the project for the first time.
+    """
+    make_virtualenv()
+    update_reqs()
+    syncdb()
+    manage_static()
+    start_supervisord()
 
+
+@task
+def deploy():
+    """
+    Deploys the latest changes
+    """
+    update_code()
+    update_reqs()
+    syncdb()
+    collect_static()
+    restart_supervisord()
+########## END COMMANDS