-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfabfile.py
More file actions
63 lines (50 loc) · 1.52 KB
/
fabfile.py
File metadata and controls
63 lines (50 loc) · 1.52 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# coding: utf-8
import os
from fabric import Config, Connection, task
hosts = ["ubuntu@127.0.0.1"]
APP_HOME = "/var/www/wepost-plugin/wepost/"
APP_NAME = "wepost"
pm2 = "/home/ubuntu/.yarn/bin/pm2"
pip = "/home/ubuntu/.pyenv/versions/wepost/bin/pip"
py = "/home/ubuntu/.pyenv/versions/wepost/bin/python"
@task(hosts=hosts, default=True)
def deploy(c):
c.run("echo $PATH && echo $SHELL")
with c.cd(APP_HOME):
c.run("git checkout .")
c.run("git pull")
c.run(f"{pip} install -q -r requirements.txt")
c.run(f"{py} manage_prod.py migrate --noinput")
c.run(f"{py} manage_prod.py collectstatic --noinput")
c.run(f"{pm2} restart wepost")
@task(hosts=hosts)
def unc(c):
"""更新nginx 配置"""
# c.local("git push")
with c.cd(APP_HOME):
c.run("git checkout .")
c.run("git pull")
c.run("pwd")
c.run("sudo cp nginx.conf /etc/nginx/")
c.run("sudo nginx -s reload")
@task(hosts=hosts)
def cc(c):
"""更新静态资源"""
with c.cd(APP_HOME):
c.run("git checkout .")
c.run("git pull")
c.run(f"{py} manage_prod.py collectstatic --noinput")
@task(hosts=hosts)
def getdb(c):
"""把数据库下载下来"""
with c.cd(APP_HOME):
c.get("db.sqlite3")
@task(hosts=hosts)
def status(c):
""" 显示应用状态 """
c.run(f"{pm2} list")
c.run(f"{pm2} show {APP_NAME}")
@task(hosts=hosts)
def upload(c,filepath):
basename = os.path.basename(filepath)
c.put(filepath, os.path.join("/tmp",basename))