-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfabfile.py
55 lines (46 loc) · 1.33 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import os
from fabric.api import *
env.hosts = ['kullo2.kullo.net']
env.user = 'root'
KULLOSERVER_DIR = '/opt/kulloserver'
@task(default=True)
def deploy():
local('make')
#TODO run tests
with cd(KULLOSERVER_DIR):
execute(update_preregistrations)
execute(update_hooks)
execute(update_message_templates)
put('kulloserver', 'kulloserver-new', mode=0755)
run('rm kulloserver-old', warn_only=True)
run('mv kulloserver kulloserver-old', warn_only=True)
run('mv kulloserver-new kulloserver')
run('systemctl stop kulloserver', warn_only=True)
#TODO migrations
run('systemctl start kulloserver')
@task
def rollback():
with cd(KULLOSERVER_DIR):
run('mv kulloserver kulloserver-new && mv kulloserver-old kulloserver')
run('systemctl stop kulloserver', warn_only=True)
#TODO migrations
run('systemctl start kulloserver')
@task
def update_preregistrations():
with cd(KULLOSERVER_DIR):
put('config/preregistrations.csv', 'config/preregistrations.csv')
@task
def update_hooks():
with cd(KULLOSERVER_DIR):
put('config/hooks', 'config')
run('chmod +x config/hooks/*')
@task
def update_message_templates():
with cd(KULLOSERVER_DIR):
put('config/message_templates', 'config')
@task
def update_goose():
gopath = os.environ['GOPATH']
local('make goose')
with cd(KULLOSERVER_DIR):
put(gopath + '/bin/goose', 'goose', mode=0755)