-
Notifications
You must be signed in to change notification settings - Fork 0
/
fabfile.py
47 lines (37 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
from fabric import task
from invoke import run as local
remote_path = "/home/natebeaty/apps/corpsey/corpsey/"
remote_hosts = ["[email protected]"]
git_branch = "master"
# deploy
@task(hosts=remote_hosts)
def deploy(c,assets="no"):
update(c)
# `fab deploy --assets=y` to compile new assets
if assets != "no":
compile_assets(c)
clear_cache(c)
restart(c)
def update(c):
c.run("cd {} && git pull origin {}".format(remote_path, git_branch))
def compile_assets(c):
c.run("cd {} && /home/natebeaty/apps/corpsey/env/bin/python manage.py collectstatic --noinput".format(remote_path))
def clear_cache(c):
c.run("cd {} && /home/natebeaty/apps/corpsey/env/bin/python manage.py clearcache".format(remote_path))
def restart(c):
c.run("/home/natebeaty/apps/corpsey/stop")
c.run("/home/natebeaty/apps/corpsey/start")
@task(hosts=remote_hosts)
def install(c):
print("Updating requirements...")
c.run("cd {} && /home/natebeaty/apps/corpsey/env/bin/python -m pip install -r requirements.txt --use-deprecated=legacy-resolver".format(remote_path))
@task(hosts=remote_hosts)
def syncdb(c):
c.run("cd {} && /home/natebeaty/apps/corpsey/env/bin/python manage.py syncdb".format(remote_path))
@task(hosts=remote_hosts)
def migrate(c):
c.run("cd {} && /home/natebeaty/apps/corpsey/env/bin/python manage.py migrate".format(remote_path))
# local commands
# @task
# def assets(c):
# local("npx gulp --production")