You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
149 lines
3.9 KiB
149 lines
3.9 KiB
# -*- coding: utf-8 -*-
|
|
from os.path import join, basename
|
|
from collections import namedtuple
|
|
|
|
from fabric.api import *
|
|
|
|
env.roledefs = {
|
|
'dev': ['root@176.121.11.165'],
|
|
'prod': ['root@176.121.11.162'],
|
|
}
|
|
env.passwords = {
|
|
'root@176.121.11.165:22': 'ue6R287QZfMc',
|
|
'root@176.121.11.162:22': 'XcS2jx5e8k6n',
|
|
}
|
|
|
|
REMOTE_HOME_DIR = '/home/www/expomap/'
|
|
LOCAL_HOME_DIR = '/home/alexander/projects/expomap/'
|
|
|
|
nginx_conf = '/etc/nginx/sites-available/hit.expomap.ru'
|
|
apache2_conf = '/etc/apache2/sites-available/proj.com'
|
|
settings_conf = join(REMOTE_HOME_DIR, 'proj/settings.py')
|
|
services = ['nginx', 'apache2']
|
|
|
|
|
|
def set_host(host):
|
|
env.hosts = env.roledefs.get(host)
|
|
env.role = host
|
|
|
|
|
|
def dev():
|
|
set_host('dev')
|
|
|
|
|
|
def prod():
|
|
set_host('prod')
|
|
|
|
|
|
def get_configs():
|
|
localdir = join(LOCAL_HOME_DIR, 'support/', env.role)
|
|
get(nginx_conf, localdir)
|
|
get(apache2_conf, localdir)
|
|
get(join(REMOTE_HOME_DIR, 'schema.xml'), localdir)
|
|
get(settings_conf, localdir)
|
|
|
|
|
|
def put_configs():
|
|
localdir = join(LOCAL_HOME_DIR, 'support/', env.role)
|
|
# nginx
|
|
put(join(localdir, basename(nginx_conf)),
|
|
nginx_conf)
|
|
# apache2
|
|
put(join(localdir, basename(apache2_conf)),
|
|
apache2_conf)
|
|
# settings
|
|
put(join(localdir, basename(settings_conf)),
|
|
settings_conf)
|
|
|
|
|
|
def call_state(state, only=None):
|
|
if only is not None and only in services:
|
|
run('service {only} {state}'.format(only=only, state=state))
|
|
return
|
|
for service in services:
|
|
run('service {service} {state}'.format(service=service, state=state))
|
|
|
|
def put_1345():
|
|
call_state('stop', only='nginx')
|
|
with cd(REMOTE_HOME_DIR):
|
|
run('git pull')
|
|
# put_configs()
|
|
call_state('start', only='nginx')
|
|
|
|
|
|
def chown():
|
|
with cd(REMOTE_HOME_DIR):
|
|
run('chown -Rv www-data:www-data .')
|
|
|
|
|
|
def pull(with_configs=False):
|
|
with cd(REMOTE_HOME_DIR):
|
|
call_state('stop', only='apache2')
|
|
run('git pull')
|
|
if with_configs:
|
|
put_configs()
|
|
call_state('start', only='apache2')
|
|
|
|
|
|
def stage3_pre_final():
|
|
with cd(REMOTE_HOME_DIR):
|
|
run('pip install pandas')
|
|
run('pip install django-rosetta==0.7.6')
|
|
run('git checkout master')
|
|
run('git pull')
|
|
call_state('stop')
|
|
put_configs()
|
|
run('python manage.py migrate conference 0001 --fake')
|
|
run('python manage.py migrate conference')
|
|
run('python manage.py migrate expobanner')
|
|
run('python manage.py migrate theme 0001 --fake')
|
|
run('python manage.py migrate theme 0002')
|
|
run('python manage.py migrate article 0001 --fake')
|
|
run('python manage.py migrate article 0002')
|
|
run('python manage.py migrate stats_collector')
|
|
run('python manage.py crontab remove')
|
|
run('python manage.py crontab add')
|
|
chown()
|
|
call_state('start')
|
|
|
|
|
|
def stage3_release():
|
|
call_state('stop')
|
|
with cd(REMOTE_HOME_DIR):
|
|
# run('python manage.py themeblog_to_blog')
|
|
run('git fetch')
|
|
run('git checkout stage3_release')
|
|
run('git pull')
|
|
# run('python manage.py migrate settings 0002 --fake')
|
|
run('python manage.py migrate settings')
|
|
run('python manage.py migrate article 0003')
|
|
chown()
|
|
call_state('start')
|
|
|
|
|
|
def c_fix():
|
|
with cd(REMOTE_HOME_DIR):
|
|
call_state('stop', only='apache2')
|
|
run('git pull')
|
|
run('python manage.py migrate expobanner')
|
|
call_state('start', only='apache2')
|
|
|
|
|
|
def stage4_firstrun():
|
|
with cd(REMOTE_HOME_DIR):
|
|
run('git fetch')
|
|
run('git checkout stage4')
|
|
run('git checkout -- proj/settings.py')
|
|
pull(with_configs=True)
|
|
run('python manage.py syncdb')
|
|
|
|
|
|
def stage4():
|
|
with cd(REMOTE_HOME_DIR):
|
|
run('python manage.py syncdb')
|
|
|
|
|
|
def ticket1395():
|
|
# stage4
|
|
with cd(REMOTE_HOME_DIR):
|
|
run('python manage.py accounts_check_url')
|
|
|