-
-
Notifications
You must be signed in to change notification settings - Fork 104
/
fabfile.py
74 lines (51 loc) · 1.45 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
from fabric.api import env, task, local, cd, lcd, run, sudo, put
from tempfile import NamedTemporaryFile
env.use_ssh_config = True
env.hosts = ["skylines@skylines"]
env.timeout = 30
APP_DIR = "/home/skylines"
SRC_DIR = "%s/src" % APP_DIR
@task
def deploy(branch="master", force=False):
push(branch, force)
restart()
@task
def deploy_ember():
with lcd("ember"):
local("node_modules/.bin/ember deploy production -v --activate")
@task
def push(branch="HEAD", force=False):
cmd = "git push %s:%s %s:master" % (env.host_string, SRC_DIR, branch)
if force:
cmd += " --force"
local(cmd)
@task
def restart():
with cd(SRC_DIR):
run("git reset --hard")
run("pipenv install")
# do database migrations
manage("migrate upgrade")
# restart services
restart_service("caddy")
reload_service("skylines")
reload_service("mapproxy")
restart_service("tracking")
restart_service("celery")
@task
def restart_service(service):
run("systemctl --user restart %s" % service)
@task
def reload_service(service):
run("systemctl --user reload %s" % service)
@task
def manage(cmd, user=None):
with cd(SRC_DIR):
if user:
sudo("pipenv run ./manage.py %s" % cmd, user=user)
else:
run("pipenv run ./manage.py %s" % cmd)
@task
def clean_mapproxy_cache():
with cd(SRC_DIR):
run("rm -rv mapproxy/cache_data/")