Commits

Mikhail Korobov committed 61b8378

Undeploy command. Fix #7.

Comments (0)

Files changed (2)

 CHANGES
 =======
 
+dev
+---
+- Debian Squeeze support;
+- the usage of ``env.user`` is discouraged;
+- ``fab_deploy.utils.print_env`` command
+- ``fab_deploy.deploy.undeploy`` command
+- better ``run_as`` implementation
+
+In order to upgrade from 0.2 please remove any usages of ``env.user`` from the
+code, e.g. before upgrade::
+
+    def my_site():
+        env.hosts = ['example.com']
+        env.user = 'foo'
+        #...
+
+After upgrade::
+
+    def my_site():
+        env.hosts = ['foo@example.com']
+        #...
+
+
 0.2 (2011-02-09)
 ----------------
 

fab_deploy/deploy.py

 #coding: utf-8
 from __future__ import with_statement
-from fabric.api import env, run, local, settings, cd
+from fabric.api import *
+from fabric.contrib.console import confirm
 from fabric.contrib.files import upload_template
 
-from fab_deploy.utils import upload_config_template, delete_pyc
+from fab_deploy.utils import upload_config_template, delete_pyc, run_as
 from fab_deploy.virtualenv import pip_install, pip_update
 from fab_deploy.django_commands import compress, migrate, syncdb, test
 from fab_deploy.system import prepare_server
     if 'notest' not in args:
         test()
 
+def undeploy():
+    """ Shuts site down. This command doesn't clean everything, e.g.
+    user data (database, backups) is preserved. """
+
+    if not confirm("Do you wish to undeploy host %s?" % env.hosts[0], default=False):
+        abort("Aborting.")
+
+    @run_as('root')
+    def wipe_web():
+        run('rm -f /etc/nginx/sites-enabled/'+env.conf['INSTANCE_NAME'])
+        run('a2dissite ' + env.conf['INSTANCE_NAME'])
+        run('invoke-rc.d nginx reload')
+        run('invoke-rc.d apache2 reload')
+
+    wipe_web()
+    run('rm -rf %s' % env.conf['SRC_DIR'])