Skip to content

Instantly share code, notes, and snippets.

@trey
Forked from kogakure/fabfile.py
Created February 18, 2009 16:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trey/66406 to your computer and use it in GitHub Desktop.
Save trey/66406 to your computer and use it in GitHub Desktop.
Fabric for Django
#!/usr/bin/python
# -*- coding: utf-8 -*-
set(
fab_hosts = ['host.com'],
fab_user = 'user',
server_path = '/home/user/django/apache2/bin',
project_path = '/home/user/django/project',
memcached_ip = 'IP',
memcached_port = 'PORT',
memcached_size = '20', # in MByte
)
def deploy():
"Push local changes, pull changes on server, delete compiled files, restart server"
local('git push;', fail='warn')
run('cd $(project_path)/; git pull; delpyc', fail='warn')
restart_server()
def stop_server():
"Stop Apache"
run('$(server_path)/stop', fail='warn')
def start_server():
"Start Apache"
run('$(server_path)/start', fail='warn')
def restart_server():
"Restart Apache"
run('$(server_path)/stop', fail='warn')
run('$(server_path)/start', fail='warn')
def restart_memcached():
"Restart Memcached"
run('kill `pgrep -u $LOGNAME memcached`', fail='warn')
run('/usr/local/bin/memcached -d -l $(memcached_ip) -m $(memcached_size) -p $(memcached_port)', fail='warn')
restart_server()
@kogakure
Copy link

There are some changes for Fabric 0.9+

@trey
Copy link
Author

trey commented Jun 30, 2010

Cool. Thanks for the heads-up.

@kogakure
Copy link

kogakure commented Jul 1, 2010

Fabric has many nice functions now, even though I didn’t needed them in this script. The documentation is now at http://fabfile.org/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment