-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfabfile.py
41 lines (33 loc) · 823 Bytes
/
fabfile.py
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
"""
fabric file used for remote deploy and logging
"""
from __future__ import with_statement
from fabric.api import *
# or @hosts
env.hosts = ['[email protected]']
CODE_DIR = '/var/www/finToFaBot'
def deploy():
"""
run fab deploy to deploy updated code
"""
with cd(CODE_DIR):
run('git checkout -- .')
run('git rev-parse HEAD > ./.gitPrevHead.bak')
run('git pull')
run('pm2 reload finToFaBot')
def status():
"""
run 'fab status' to see bot status
"""
run('pm2 show finToFaBot')
def log():
"""
run 'fab log' to see bot logs.
"""
run('pm2 logs finToFaBot --lines 100')
def rollback():
"""
run 'fab rollback' to rollback to previous commit
"""
with cd(CODE_DIR):
run('git checkout `cat ./.gitPrevHead.bak`')