########## FILE MANAGEMENT
@task
def manage_static():
+ """
+ Collects, compresses and uploads static files.
+ """
collect_static()
compress_static()
upload_static()
env.run('git pull && git checkout %s' % env.branch)
-def manage_supervisor_proc(proc, action):
+@task
+def start_supervisord():
+ """
+ Starts supervisord
+ """
+ with _virtualenv():
+ config_file = os.path.join(env.confs, 'supervisord.conf')
+ env.run('supervisord -c %s' % config_file)
+
+
+@task
+def stop_supervisord():
+ """
+ Restarts supervisord
+ """
+ with _virtualenv():
+ config_file = os.path.join(env.confs, 'supervisord.conf')
+ env.run('supervisorctl -c %s shutdown' % config_file)
+
+
+@task
+def restart_supervisord():
+ """
+ Restarts supervisord
+ """
+ stop_supervisord()
+ start_supervisord()
+
+
+def supervisorctl(action, process):
"""
Takes as arguments the name of the process as is
defined in supervisord.conf and the action that should
be performed on it: start|stop|restart.
"""
supervisor_conf = os.path.join(env.confs, 'supervisord.conf')
- env.run('supervisorctl -c %s %s %s' % (supervisor_conf, proc, action))
+ env.run('supervisorctl -c %s %s %s' % (supervisor_conf, action, process))
@task
"""
Starts the celeryd process
"""
- manage_supervisor_proc('celeryd', 'start')
+ supervisorctl('start', 'celeryd')
@task
"""
Stops the celeryd process
"""
- manage_supervisor_proc('celeryd', 'stop')
+ supervisorctl('stop', 'celeryd')
@task
"""
Restarts the celeryd process
"""
- manage_supervisor_proc('celeryd', 'restart')
+ supervisorctl('restart', 'celeryd')
@task
"""
Starts the gunicorn process
"""
- manage_supervisor_proc('gunicorn', 'start')
+ supervisorctl('start', 'gunicorn')
@task
"""
Stops the gunicorn process
"""
- manage_supervisor_proc('gunicorn', 'stop')
+ supervisorctl('stop', 'gunicorn')
@task
"""
Restarts the gunicorn process
"""
- manage_supervisor_proc('gunicorn', 'restart')
+ supervisorctl('restart', 'gunicorn')
@task