diff --git a/app/deploy/debian.py b/app/deploy/debian.py index fcdd7ac..7cac39a 100644 --- a/app/deploy/debian.py +++ b/app/deploy/debian.py @@ -18,15 +18,6 @@ class Debian(Node): getattr(self, "_" + item['action'])(item['params']) - # Actions - # def _virtualenv(params): - # """ - # Allows running commands on the server - # with an active virtualenv - # """ - # with cd(fabconf['APPS_DIR']): - # _virtualenv_command(_render(params)) - def _apt(self, params): """ Runs apt-get install commands diff --git a/app/deploy/tasks.py b/app/deploy/tasks.py index 7ff2fb5..0526d75 100644 --- a/app/deploy/tasks.py +++ b/app/deploy/tasks.py @@ -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 diff --git a/app/deploy/zuykov.py b/app/deploy/zuykov.py index d54aa08..384b689 100644 --- a/app/deploy/zuykov.py +++ b/app/deploy/zuykov.py @@ -23,23 +23,6 @@ class ZuykovWebSystem(Node): roles: web, engine, database """ - # @map_roles(host='database') - # class Database(<): - # def create(self): - # host = settings.DATABASES['default'] - - # # Создаём группу безопасности - # security_group = self._ec2_mysql_security_group() - # # Создаём группу параметров - - # # Запускаем инстанс - # self._rds_create_instance( - # 'database', - # host['NAME'], - # host['USER'], - # host['PASSWORD']) - - @map_roles(host='web') class Application(DjangoDeployment): def configure_base(self): @@ -53,6 +36,9 @@ class ZuykovWebSystem(Node): self.checkout() self.pull() + def collect_static(self): + self.run_management_command('collectstatic --noinput') + def checkout(self, commit="."): with self.hosts.cd(settings.PROJECT_DIR, expand=True): self.hosts.run("git checkout '%s'" % esc1(commit)) @@ -63,35 +49,22 @@ class ZuykovWebSystem(Node): def create(self): - self.Application.hello() # Если созданы — удалить - # # Предварительно спросить - # self.Frontend.create() - - # self.Engine.create() - - def static(self): - self.Application.run_management_command('collectstatic --noinput') - - def frontend_update(self): - self.Application.update() - self.Application.run_management_command('collectstatic --noinput') - self.Application.restart() + # TODO: Предварительно спросить + self.Frontend.create() + self.Engine.create() def deploy(self): self.Application.update() self.Application.python_packages_install() - self.Application.run_management_command('collectstatic --noinput') + self.Application.collect_static() self.Application.restart() - # self.Engine.migrate() - - # self.Frontend.restart() - - # self.Engine.restart() - - + def update(self): + self.Application.update() + self.Application.collect_static() + self.Application.restart() \ No newline at end of file