Убрал лишнее из деплоя

master
Alexander Kondratyev 9 years ago
parent d3de610a10
commit 7aa0b2ddfc
  1. 9
      app/deploy/debian.py
  2. 60
      app/deploy/tasks.py
  3. 49
      app/deploy/zuykov.py

@ -18,15 +18,6 @@ class Debian(Node):
getattr(self, "_" + item['action'])(item['params']) 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): def _apt(self, params):
""" """
Runs apt-get install commands Runs apt-get install commands

@ -1,39 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- 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 = [ common_configure = [
# First command as regular user # First command as regular user
{"action": "run", "params": "whoami"}, {"action": "run", "params": "whoami"},
@ -145,32 +112,7 @@ reload_uwsgi = [
{"action": "sudo", "params": "service uwsgi restart", {"action": "sudo", "params": "service uwsgi restart",
"message": "Restarting uwsgi"}, "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 = [ web_configure += reload_uwsgi + reload_nginx + create_uwsgi_links + create_nginx_links
{"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"},
]

@ -23,23 +23,6 @@ class ZuykovWebSystem(Node):
roles: web, engine, database 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') @map_roles(host='web')
class Application(DjangoDeployment): class Application(DjangoDeployment):
def configure_base(self): def configure_base(self):
@ -53,6 +36,9 @@ class ZuykovWebSystem(Node):
self.checkout() self.checkout()
self.pull() self.pull()
def collect_static(self):
self.run_management_command('collectstatic --noinput')
def checkout(self, commit="."): def checkout(self, commit="."):
with self.hosts.cd(settings.PROJECT_DIR, expand=True): with self.hosts.cd(settings.PROJECT_DIR, expand=True):
self.hosts.run("git checkout '%s'" % esc1(commit)) self.hosts.run("git checkout '%s'" % esc1(commit))
@ -63,35 +49,22 @@ class ZuykovWebSystem(Node):
def create(self): def create(self):
self.Application.hello()
# Если созданы — удалить # Если созданы — удалить
# # Предварительно спросить # TODO: Предварительно спросить
# self.Frontend.create() 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()
self.Engine.create()
def deploy(self): def deploy(self):
self.Application.update() self.Application.update()
self.Application.python_packages_install() self.Application.python_packages_install()
self.Application.run_management_command('collectstatic --noinput') self.Application.collect_static()
self.Application.restart() self.Application.restart()
# self.Engine.migrate() def update(self):
self.Application.update()
# self.Frontend.restart() self.Application.collect_static()
self.Application.restart()
# self.Engine.restart()
Loading…
Cancel
Save