-
-
Save trey/66406 to your computer and use it in GitHub Desktop.
Fabric for Django
This file contains hidden or 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
#!/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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fabric has many nice functions now, even though I didn’t needed them in this script. The documentation is now at http://fabfile.org/