mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 06:42:16 +00:00
Updated fab for uWSGI
This commit is contained in:
66
fabfile.py
vendored
66
fabfile.py
vendored
@@ -2,6 +2,8 @@ from __future__ import with_statement
|
|||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
from fabric.api import *
|
from fabric.api import *
|
||||||
|
from fabric.contrib.files import *
|
||||||
|
from fabric.utils import warn
|
||||||
from hashlib import sha1
|
from hashlib import sha1
|
||||||
|
|
||||||
env.repo = 'git://dev.dredd.it/dreddit-auth.git'
|
env.repo = 'git://dev.dredd.it/dreddit-auth.git'
|
||||||
@@ -77,6 +79,7 @@ def setup_db():
|
|||||||
run('if [ ! -e dbsettings.py ]; then cp dbsettings.py.example dbsettings.py; fi' % env)
|
run('if [ ! -e dbsettings.py ]; then cp dbsettings.py.example dbsettings.py; fi' % env)
|
||||||
run('env/bin/python manage.py syncdb --noinput --migrate')
|
run('env/bin/python manage.py syncdb --noinput --migrate')
|
||||||
|
|
||||||
|
|
||||||
def generate_brokersettings():
|
def generate_brokersettings():
|
||||||
"""
|
"""
|
||||||
Generates the brokersettings file
|
Generates the brokersettings file
|
||||||
@@ -88,6 +91,7 @@ def generate_brokersettings():
|
|||||||
out = open('brokersettings.py', 'w')
|
out = open('brokersettings.py', 'w')
|
||||||
out.write(cnf % env)
|
out.write(cnf % env)
|
||||||
|
|
||||||
|
|
||||||
def setup_rabbitmq():
|
def setup_rabbitmq():
|
||||||
"""
|
"""
|
||||||
Setup the RabbitMQ instance on the system (requires sudo access)
|
Setup the RabbitMQ instance on the system (requires sudo access)
|
||||||
@@ -108,6 +112,7 @@ def setup_rabbitmq():
|
|||||||
put('./brokersettings.py', '%(path)s/dreddit-auth/' % env)
|
put('./brokersettings.py', '%(path)s/dreddit-auth/' % env)
|
||||||
os.unlink('brokersettings.py')
|
os.unlink('brokersettings.py')
|
||||||
|
|
||||||
|
|
||||||
def deploy_repo():
|
def deploy_repo():
|
||||||
"""
|
"""
|
||||||
Do the initial repository checkout
|
Do the initial repository checkout
|
||||||
@@ -133,6 +138,7 @@ def update_repo():
|
|||||||
with cd('%(path)s/dreddit-auth/' % env):
|
with cd('%(path)s/dreddit-auth/' % env):
|
||||||
run('git pull')
|
run('git pull')
|
||||||
|
|
||||||
|
|
||||||
def reset_repo():
|
def reset_repo():
|
||||||
"""
|
"""
|
||||||
Does a hard reset on the remote repo
|
Does a hard reset on the remote repo
|
||||||
@@ -155,38 +161,68 @@ def migrate():
|
|||||||
run('env/bin/python manage.py migrate')
|
run('env/bin/python manage.py migrate')
|
||||||
|
|
||||||
|
|
||||||
def start():
|
def start_celeryd():
|
||||||
"""
|
"""
|
||||||
Start the FastCGI server
|
Start the celeryd server
|
||||||
"""
|
"""
|
||||||
require('hosts')
|
require('hosts')
|
||||||
require('path')
|
require('path')
|
||||||
|
|
||||||
with cd('%(path)s/dreddit-auth/' % env):
|
with cd('%(path)s/dreddit-auth/' % env):
|
||||||
run('rm -f off.html')
|
run('./manage.py celeryd_detach -l INFO -B --pidfile logs/celery.pd -f logs/celeryd.log -n auth-processor' % env)
|
||||||
run('./start.sh')
|
|
||||||
|
|
||||||
|
|
||||||
def stop():
|
def stop_celeryd():
|
||||||
"""
|
"""
|
||||||
Stop any running FCGI instance
|
Stop any running FCGI instance
|
||||||
"""
|
"""
|
||||||
require('hosts')
|
require('hosts')
|
||||||
require('path')
|
require('path')
|
||||||
|
|
||||||
|
if exists('logs/celeryd.pid'):
|
||||||
|
run('kill `cat logs/celeryd.pid`')
|
||||||
|
else:
|
||||||
|
warn('celeryd isn\'t running')
|
||||||
|
|
||||||
|
def restart_celeryd():
|
||||||
|
"""
|
||||||
|
Restart the celery daemon
|
||||||
|
"""
|
||||||
|
stop_celeryd()
|
||||||
|
time.sleep(2)
|
||||||
|
start_celeryd()
|
||||||
|
|
||||||
|
|
||||||
|
def start_uwsgi():
|
||||||
with cd('%(path)s/dreddit-auth/' % env):
|
with cd('%(path)s/dreddit-auth/' % env):
|
||||||
run('rm -f off.html')
|
run('uwsgi -s logs/uwsgi.sock -M -p 5 --vhost --no-site -d logs/uwsgi.log --pidfile logs/uwsgi.pid --vacuum' % env)
|
||||||
run('ln -s templates/off.html')
|
|
||||||
run('kill `cat ./logs/celeryd.pid`')
|
|
||||||
run('kill `cat ./logs/auth.pid`')
|
def stop_uwsgi():
|
||||||
run('rm -f ./logs/celeryd.pid')
|
with cd('%(path)s/dreddit-auth/' % env):
|
||||||
run('rm -f ./logs/auth.pid')
|
if exists('logs/uwsgi.pid'):
|
||||||
|
run('kill `cat logs/uwsgi.pid`')
|
||||||
|
else:
|
||||||
|
warn('uWSGI isn\'t running')
|
||||||
|
|
||||||
|
|
||||||
|
def restart_uwsgi():
|
||||||
|
stop_uwsgi()
|
||||||
|
time.sleep(0.5)
|
||||||
|
start_uwsgi()
|
||||||
|
|
||||||
|
|
||||||
|
def start():
|
||||||
|
start_uwsgi()
|
||||||
|
start_celeryd()
|
||||||
|
|
||||||
|
|
||||||
|
def stop():
|
||||||
|
stop_celeryd()
|
||||||
|
stop_uwsgi()
|
||||||
|
|
||||||
|
|
||||||
def restart():
|
def restart():
|
||||||
"""
|
|
||||||
Restart the FCGI server
|
|
||||||
"""
|
|
||||||
stop()
|
stop()
|
||||||
time.sleep(2)
|
time.sleep(5)
|
||||||
start()
|
start()
|
||||||
|
|||||||
Reference in New Issue
Block a user