forked from strets123/chembiohub_ws
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fabfile.py
55 lines (43 loc) · 2.35 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
from fabric.operations import prompt, local, run, sudo
from fabric.api import cd, prefix
from fabric.state import env
from fabric.context_managers import shell_env
try:
from server_configs import SERVER_CONFIGS
except ImportError:
print """ You Must provide a file server_configs.py to use fabric for deployment.
It should have a format:
SERVER_CONFIGS = [{"host_string": "my-server.com",
"user" : "astretton",
"directory": "/srv/chembiohub/chembiohub_ws",
"conda_env_path": "/home/chembiohub/anaconda2/envs/hub",
"url": "https://my-server.com/hub",
"user_running_chembiohub" : "chembiohub"},
{"host_string": "my-server2.com",
"user" : "astretton",
"directory": "/srv/chembiohub/chembiohub_ws",
"conda_env_path": "/home/chembiohub/anaconda2/envs/hub",
"url": "https://my-server2.com/hub",
"user_running_chembiohub" : "chembiohub"}]
"""
def deploy():
for index, conf in enumerate(SERVER_CONFIGS):
print ("%d: %s" % (index + 1, conf["url"]) )
prompt("Which instance of the application would you like to deploy to?", key="instance_number")
instance = int(env.instance_number) -1
env.update(SERVER_CONFIGS[instance])
new_path = env.conda_env_path + "/bin:$PATH"
with shell_env(PATH=new_path, CONDA_ENV_PATH=env.conda_env_path, ):
with cd(env.directory):
sudo("git pull origin master", user=env.user_running_chembiohub)
sudo("git submodule foreach git pull origin master", user=env.user_running_chembiohub)
# sudo("conda install -y --file anaconda_requirements.txt" , user=env.user_running_chembiohub)
sudo("pip install -r pip_requirements.txt", user=env.user_running_chembiohub)
sudo("python manage.py migrate", user=env.user_running_chembiohub)
with cd(env.directory + "/src/ng-chem"):
sudo("bower install", user=env.user_running_chembiohub)
with cd(env.directory):
sudo("python manage.py collectstatic --noinput", user=env.user_running_chembiohub)
with cd(env.directory):
sudo("python manage.py log_all_users_out", user=env.user_running_chembiohub)
sudo("supervisorctl reload")