Added another task that handles the first deploy.
authorLucian Ursu <lucian.ursu@gmail.com>
Thu, 28 Feb 2013 19:27:32 +0000 (21:27 +0200)
committerLucian Ursu <lucian.ursu@gmail.com>
Thu, 28 Feb 2013 19:27:32 +0000 (21:27 +0200)
fabfile.py

index ada9fed7cf1aa2be0492f845e8c884c219440dfb..65a5e9d5f4adb44cc6db99d790665fc112b2a71e 100755 (executable)
@@ -3,7 +3,7 @@
 import os
 from contextlib import contextmanager as _contextmanager
 
-from fabric.api import cd, env, prefix, run, task, local
+from fabric.api import cd, env, prefix, run, task, local, settings
 
 
 ########## GLOBALS
@@ -239,6 +239,32 @@ def restart_gunicorn():
     supervisorctl('restart', 'gunicorn')
 
 
+@task
+def first_deploy():
+    """
+    Sets up and deploys the project for the first time.
+    """
+    # If we're on the local machine, there's no point in cloning
+    # the project, because it's already been cloned. Otherwise
+    # the user couldn't run this file
+    if env.run == run:
+        # We're doing this to filter out the hosts that have
+        # already been setup and deployed to
+        with settings(warn_only=True):
+            if env.run('test -d %s' % env.project).failed:
+                return
+        clone()
+
+    make_virtualenv()
+    update_reqs()
+    syncdb()
+    manage_static()
+
+    # We don't start supervisor on development machines
+    if env.run == run:
+        start_supervisord()
+
+
 @task
 def deploy():
     """