|
|
|
|
@ -1,39 +1,6 @@ |
|
|
|
|
#!/usr/bin/env python |
|
|
|
|
# -*- coding: utf-8 -*- |
|
|
|
|
|
|
|
|
|
''' |
|
|
|
|
-------------------------------------------------------------------------------------- |
|
|
|
|
tasks.py |
|
|
|
|
-------------------------------------------------------------------------------------- |
|
|
|
|
A set of tasks to manage your AWS Django deployment. |
|
|
|
|
|
|
|
|
|
author : Ashok Fernandez (github.com/ashokfernandez/) |
|
|
|
|
credit : Derived from files in https://github.com/gcollazo/Fabulous |
|
|
|
|
date : 11 / 3 / 2014 |
|
|
|
|
|
|
|
|
|
Tasks include: |
|
|
|
|
- configure_instance : Configures a new EC2 instance (as definied in settings.py) and return's it's public dns |
|
|
|
|
This takes around 8 minutes to complete. |
|
|
|
|
|
|
|
|
|
- update_packages : Updates the python packages on the server to match those found in requirements/common.txt and |
|
|
|
|
requirements/prod.txt |
|
|
|
|
|
|
|
|
|
- deploy : Pulls the latest commit from the master branch on the server, collects the static files, syncs the db and |
|
|
|
|
restarts the server |
|
|
|
|
|
|
|
|
|
- reload_gunicorn : Pushes the gunicorn startup script to the servers and restarts the gunicorn process, use this if you |
|
|
|
|
have made changes to templates/start_gunicorn.bash |
|
|
|
|
|
|
|
|
|
- reload_nginx : Pushes the nginx config files to the servers and restarts the nginx, use this if you |
|
|
|
|
have made changes to templates/nginx-app-proxy or templates/nginx.conf |
|
|
|
|
|
|
|
|
|
- reload_supervisor : Pushes the supervisor config files to the servers and restarts the supervisor, use this if you |
|
|
|
|
have made changes to templates/supervisord-init or templates/supervisord.conf |
|
|
|
|
|
|
|
|
|
''' |
|
|
|
|
|
|
|
|
|
# Spawns a new EC2 instance (as definied in djangofab_conf.py) and return's it's public dns |
|
|
|
|
# This takes around 8 minutes to complete. |
|
|
|
|
common_configure = [ |
|
|
|
|
# First command as regular user |
|
|
|
|
{"action": "run", "params": "whoami"}, |
|
|
|
|
@ -145,32 +112,7 @@ reload_uwsgi = [ |
|
|
|
|
|
|
|
|
|
{"action": "sudo", "params": "service uwsgi restart", |
|
|
|
|
"message": "Restarting uwsgi"}, |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
web_configure += reload_uwsgi + reload_nginx + create_uwsgi_links + create_nginx_links |
|
|
|
|
|
|
|
|
|
engine_configure = [ |
|
|
|
|
# List of pypi packages to install |
|
|
|
|
{"action": "run", "params": "cp -r ~/%(PROJECT_NAME)s/env/share/voiceid ~/%(PROJECT_NAME)s/env/local/share/", |
|
|
|
|
"message":"Move voiceid"}, |
|
|
|
|
|
|
|
|
|
{"action": "apt", "params": ["supervisor"], |
|
|
|
|
"message":"Installing supervisor"}, |
|
|
|
|
|
|
|
|
|
{"action": "put_template", "params": {"template": "%(BASE_DIR)s/app/conf/supervisor.conf.template", |
|
|
|
|
"destination": "/home/%(SERVER_USERNAME)s/%(PROJECT_NAME)s/app/conf/supervisor.conf"}}, |
|
|
|
|
{"action": "sudo", "params": |
|
|
|
|
"ln -s /home/%(SERVER_USERNAME)s/%(PROJECT_NAME)s/app/conf/supervisor.conf /etc/supervisor/conf.d/%(PROJECT_NAME)s.conf"}, |
|
|
|
|
{"action": "sudo", "params": "service supervisor restart", |
|
|
|
|
"message": "Restarting supervisor"}, |
|
|
|
|
|
|
|
|
|
# Запстить очереди |
|
|
|
|
# TODO: настроить редис как внешний сервер |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
reload_supervisor = [ |
|
|
|
|
{"action": "put_template", "params": {"template": "%(BASE_DIR)s/app/conf/supervisor.conf.template", |
|
|
|
|
"destination": "/home/%(SERVER_USERNAME)s/%(PROJECT_NAME)s/app/conf/supervisor.conf"}}, |
|
|
|
|
{"action": "sudo", "params": "service supervisor restart", |
|
|
|
|
"message": "Restarting supervisor"}, |
|
|
|
|
] |
|
|
|
|
web_configure += reload_uwsgi + reload_nginx + create_uwsgi_links + create_nginx_links |
|
|
|
|
|