-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfabfile.py
More file actions
71 lines (62 loc) · 2.15 KB
/
Copy pathfabfile.py
File metadata and controls
71 lines (62 loc) · 2.15 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
64
65
66
67
68
69
70
71
from fabric.api import env, local, run, cd, sudo, open_shell, settings
# For setting up SSH key on VM: https://help.github.com/articles/generating-ssh-keys/
env.user = ""
env.password = ""
env.hosts = ["classcapture.ncsa.illinois.edu"]
git_base_url = "https://github.com/cs-education/"
git_repo_name = "ClassCapture_Web"
def checkout():
"""
Checkout the code on the VM, install npm/bower dependencies
Also, changes current directory to the checked out repo
"""
must_clone_repo = False
with settings(warn_only=True): # makes it so that test -d won't cause an interruption if it fails
must_clone_repo = run("test -d %s" % git_repo_name).failed
if must_clone_repo:
run("git clone %s%s.git" % (git_base_url, git_repo_name))
with cd("~/%s" % git_repo_name):
run("git pull origin master")
# install bower/npm dependencies
run("bower install")
run("npm install")
def start_server():
"""
Start the server on the VM
Uses forever package to start it as a continuous daemon
"""
with cd("~/%s" % git_repo_name):
run("pm2 start app.json")
def reload_server(user, password, shell_after=True):
"""
Restarts server...If its in cluster mode, will be able to reload with 0 downtime
"""
env.user = user
env.password = password
checkout()
with cd("~/%s" % git_repo_name):
run("pm2 reload app.json")
if shell_after:
open_shell()
def update_frontend(user, password, shell_after=True):
"""
Just rebuilds the application frontend files
Server will then be able to just pull from the new files and display the front end updates
If there are updates for the server itself that serves the frontend content, use `reload_server(...)`
"""
env.user = user
env.password = password
checkout()
with cd("~/%s" % git_repo_name):
run("grunt build:dist --force")
if shell_after:
open_shell()
def deploy(user, password, shell_before=False, shell_after=True):
env.user = user
env.password = password
if shell_before:
open_shell()
checkout()
start_server()
if shell_after:
open_shell()