Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: b7f0869915
Fetching contributors…

Cannot retrieve contributors at this time

40 lines (30 sloc) 1.406 kb
#!/usr/bin/env python
Run 'fab --list' to see what commands you can run.
Requires Fabric from
import os
from getpass import getuser
from fabric.api import env, hosts, local, run, sudo
from fabric.context_managers import cd
from fabric.utils import puts
from fabric.colors import magenta
def _transfer_files(src, dst, port=22):
'''Sync from local directory to remote directory'''
assert os.getenv('SSH_AUTH_SOCK') is not None # Ensure ssh-agent is running
if not src.endswith('/'):
src = src + '/'
if dst.endswith('/'):
dst = dst[:-1]
local('rsync -avh --delete-before --copy-unsafe-links --exclude "log/*" -e "ssh -p {0}" {1} {2}'.format(port, src, dst), capture=False)
def push():
local_dir = os.getcwd()
remote_dir = '/home/' + getuser() + '/web/'
_transfer_files(local_dir, + ':' + remote_dir, env.port) # transfer the code
with cd(remote_dir):
run("rm -vf public/index.html public/about.html") # remove page caches on disk
#run("env RAILS_ENV=production rake cache:clear") # clear memcache
run("touch tmp/restart.txt") # restart passenger
sudo("restart") # delayed_job worker
puts(magenta('Success! The {0} server has been updated.'.format(env.host_string)))
Jump to Line
Something went wrong with that request. Please try again.