Added Fabric file and various small fixes to enable better deployments

This commit is contained in:
2010-07-07 13:07:07 +01:00
parent ebce7f98cb
commit 6e122a17ab
3 changed files with 99 additions and 7 deletions

5
.gitignore vendored
View File

@@ -1,11 +1,8 @@
*.pyc
*~
*.db
django/
registration/
dbsettings.py
piston
django_evolution
logs/
settingslocal.py
env
*.pid

88
fabfile.py vendored Normal file
View File

@@ -0,0 +1,88 @@
from __future__ import with_statement
from fabric.api import *
env.repo = 'git://dev.dredd.it/dreddit-auth.git'
def production():
env.hosts = ['matalok@web1.dredd.it']
env.path = '/home/matalok/auth'
def test():
env.hosts = ['auth@web2.dredd.it']
env.path = '/home/auth'
def setup():
require('hosts')
require('path')
#sudo('aptitude install python-virtualenv')
deploy_repo()
setup_virtualenv()
setup_db()
def push():
require('hosts')
require('path')
update_repo()
setup_virtualenv()
migrate()
def setup_virtualenv():
require('path')
with cd('%(path)s/dreddit-auth/' % env):
run('./setup-env.sh' % env)
def setup_db():
require('path')
with cd('%(path)s/dreddit-auth/' % env):
run('cp dbsettings.py.example dbsettings.py' % env)
run('env/bin/python manage.py syncdb --noinput --migrate')
def deploy_repo():
require('hosts')
require('path')
run('mkdir -p %(path)s' % env)
with cd(env.path):
run('git clone %(repo)s' % env)
def update_repo():
require('hosts')
require('path')
with cd('%(path)s/dreddit-auth/' % env):
run('git pull')
def migrate():
require('hosts')
require('path')
with cd('%(path)s/dreddit-auth/' % env):
run('env/bin/python manage.py migrate')
def start():
require('hosts')
require('path')
with cd('%(path)s/dreddit-auth/' % env):
run('./start.sh')
def stop():
require('hosts')
require('path')
with cd('%(path)s/dreddit-auth/' % env):
run('kill `cat auth.pid`')
run('rm -f auth.pid')
def restart()
stop()
start()

View File

@@ -1,4 +1,11 @@
#!/bin/sh
#!/bin/bash
. ./env/bin/activate
python ./manage.py runfcgi method=threaded host=127.0.0.1 port=9981
PIDFILE='auth.pid'
if [ -f $PIDFILE ]; then
kill `cat -- $PIDFILE`
rm -f -- $PIDFILE
fi
source ./env/bin/activate
./manage.py runfcgi daemonize=false pidfile=$PIDFILE host=127.0.0.1 port=9981 &