Skip to content

Instantly share code, notes, and snippets.

Created May 23, 2012 03:10
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Fabric file for deploy django+gunicorn+nginx+virutalenv
import sys
from fabric.colors import green, yellow
from fabric.contrib.console import confirm
from fabric.context_managers import cd, prefix
from fabric.operations import prompt
from fabric.api import run, local, env, sudo
env.user = 'ubuntu'
env.hosts = [''] #ip do ec2
env.app_path = '/home/seu-usuario-do-ec2/bomgusto'
env.virtualenv_path = '/path/para/seu/virtualenv'
env.pid_path = '/home/seu-usuario-do-ec2/'
#deploy for nginx+guncorn is great man....
def start_deploy():
local('fab -H ubuntu@ip do ec2 deploy_nginx')
def start_bomgusto():
sys.stdout.write(green(u'Starting the'))
with cd(env.app_path):
sudo('supervisorctl start bomgusto')
sudo('service nginx start')
sys.stdout.write(green(u' is running...'))
def stop_bomgusto():
result = sudo('supervisorctl stop bomgusto')
if result.failed:
sys.stdout.write(yellow(u'Bomgusto is not running'))
return result
sys.stdout.write(green(u' stoped'))
return result
def deploy_nginx():
result = stop_bomgusto()
run('source /home/ubuntu/enviroment/bomgusto/bin/activate')
sys.stdout.write(green(u'Activating of the virtualenv for bomgusto'))
with cd(env.app_path):
run('git pull origin master')
if confirm(u"Do u want install new pip's ?"):
if confirm(u"Do u want collectstatic ?"):
run('%sbin/python collectstatic' % (env.virtualenv_path))
if confirm(u"Do u have migrates?"):
def update_database():
with cd(env.app_path):
run("%sbin/python syncdb" % (env.virtualenv_path))
run("%sbin/python migrate" % (env.virtualenv_path))
def install_requirements():
run("%sbin/pip install -r %srequirements.txt" % (env.virtualenv_path, env.app_path))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment