-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfabfile.py
More file actions
47 lines (39 loc) · 1.37 KB
/
fabfile.py
File metadata and controls
47 lines (39 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# -*- coding: utf-8 -*-
from pathlib import Path
from fabric.api import sudo, run, cd, local, put, get, warn
from fabric.contrib.files import exists
def stop():
sudo('service nginx stop')
sudo('supervisorctl stop exotic_server:*')
sudo('supervisorctl stop exotic_proxy:*')
def start():
sudo('supervisorctl start exotic_proxy:*')
sudo('supervisorctl start exotic_server:*')
sudo('service nginx start')
def restart():
stop()
start()
def commit(message='', push='n'):
"""
Usage: fab commit:message='commit message and escaping comma\, this way',push=n
"""
local("git add . && git commit -m '{}'".format(message))
if push == 'y':
local("git push")
def deploy():
stop()
with cd('/var/www/exotic-server'):
run('git checkout .')
run('git pull')
with cd('/var/www/exotic-server/views'):
run('/home/exotic/.nvm/versions/node/v6.2.0/bin/node '
'/home/exotic/.nvm/versions/node/v6.2.0/lib/node_modules/npm '
'run build')
start()
def backup_config():
tmp_dir = Path('/tmp/exotic-server/')
if not tmp_dir.exists():
tmp_dir.mkdir(parents=True)
warn('Create path /tmp/exotic-server/')
get('/etc/nginx/nginx.conf', '/tmp/exotic-server/nginx.conf', use_sudo=True)
get('/etc/supervisor/conf.d/exotic.conf', '/tmp/exotic-server/exotic.conf', use_sudo=True)