Last active
December 14, 2015 15:09
-
-
Save mushfiq/5105914 to your computer and use it in GitHub Desktop.
Fabric boiler plate for deployment.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fabric.api import local, run, env, put | |
env.graceful = False | |
def test_server(): | |
env.user = 'your_user_name' | |
env.serverpath = '/' | |
env.site_root = 'your_app_root' | |
env.password = 'your_pass' #ssh password for user | |
# env.key_filename = ''# specify server public key | |
#lis of hossts in env.hosts | |
env.hosts = [ | |
'test.com', | |
] | |
#sample method for git pull | |
def pull(branch_name): | |
env.site_root = 'your_project_path' | |
run('cd %s && git pull origin %s' % (env.site_root, branch_name)) | |
#deploy current directories all code without fabfile.py | |
def deploy(): | |
env.files = '*' | |
env.site_name = 'your_app_name' | |
env.site_path = 'your_application_path' | |
run('rm -rf %s/%s' % (env.site_path,env.site_name)) | |
local('zip -r %s.zip -x=fabfile.py %s' % (env.site_name, env.files)) | |
put(env.site_name+'.zip',env.site_path) | |
run('cd %s && unzip %s.zip -d %s && rm %s.zip' % (env.site_root, \ | |
env.site_name, env.site_name, env.site_name)) | |
local('rm -rf %s.zip' % env.site_name) | |
#restart apache of remote host | |
def restart_apache(): | |
cmd = "/usr/local/apache2/bin/apachectl -k graceful" if (env.graceful is True) \ | |
else "service httpd restart" | |
run(cmd) | |
def latest_access_log(): | |
cmd = "tail -n 10 /var/log/apache2/access.log" | |
run(cmd) | |
def latest_error_log(): | |
cmd = "tail -n 10 /var/log/apache2/error.log" | |
run(cmd) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sudo apt-get install python-pip | |
sudo pip install fabric |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment