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.
66 lines
1.5 KiB
66 lines
1.5 KiB
# -*- coding: utf-8 -*-
|
|
from os.path import join, basename
|
|
|
|
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')
|
|
|
|
|
|
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):
|
|
run('service apache2 {state}'.format(state=state))
|
|
run('service nginx {state}'.format(state=state))
|
|
|
|
|
|
def put_1345():
|
|
call_state('stop')
|
|
run('git pull')
|
|
put_configs()
|
|
call_state('start')
|
|
|