Thejesh GN avatar Thejesh GN committed 40a3a73

fabfile for deployment

Comments (0)

Files changed (1)

maintanance/deploy/fabfile.py

+################################################################
+# It uses fabfile to build and deploy
+# Ref: http://thejeshgn.com/2012/02/02/deployment-php-python-app-using-mercurial-and-fabfile
+# usage:
+#        cd to the build folder
+#        >fab hello    
+################################################################
+from __future__ import with_statement
+from fabric.api import *
+from fabric.contrib.console import confirm
+
+def hello():
+    print("Welcome to web deployment.")
+    
+def test():
+    env.user = 'user_name'
+    env.hosts = ['100.100.100.100']
+    env.password ='password'
+    env.consumer_key ="test_xGxRxzXrxoxSxrxYxuxdxnxLxBxzQU00Q"
+
+def prod():
+    env.user = 'user_name'
+    env.hosts = ['200.200.200.200']
+    env.password ='password'
+    env.consumer_key ="prod_xGxRxzXrxoxSxrxYxuxdxnxLxBxzQU00Q"
+
+def update(version):  
+    with cd('/home/user_home/public_html/tweet4blood.com'):  
+        run('hg pull')      
+        run('hg update -C '+version)      
+    with cd('/home/user_home/public_html/tweet4blood.com/html/auth/'):
+            consumer_key_defnition = "define('CONSUMER_KEY', '"+ +"');"                         
+            run("sed -i 's/define('CONSUMER_KEY', 'xGxRxzXrxoxSxrxYxuxdxnxLxBxzQU00Q');/"+consumer_key_defnition+"/' config.php")
+
+def apache_restart():  
+    sudo('/etc/init.d/apache2 restart') 
+
+def apache_stop():  
+    sudo('/etc/init.d/apache2 stop') 
+
+def apache_start():  
+    sudo('/etc/init.d/apache2 start')
+ 
+def apache_status():
+    sudo('ps aux | egrep "(PID|apache2)"')
+
+def web_deploy(version):
+    web_stop()
+    update(version)   
+    web_start()     
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.