-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdeployment.py
46 lines (36 loc) · 1.42 KB
/
deployment.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
import os
from fabric.api import local, env
from fabric.context_managers import lcd
from common import lexists, Git
from postgres_helper import Postgres
from pip_helper import Pip
def create_env():
"""
so we assume the branch name is something like v0.6.0
we strip off the first letter and the .s so we expect
the virtualenv name to be 060
"""
Pip.create_virtual_env()
Git.checkout_branch()
Pip.set_project_directory()
with lcd(env.project_path):
Pip.install_requirements()
symlink_nginx()
Postgres.create_user_and_database()
symlink_upstart()
def symlink_nginx():
absPathNginxConf = os.path.join(env.project_path, "etc/nginx.conf")
if not lexists(absPathNginxConf):
raise ValueError("we expect an nginx conf to exist")
symlink_name = '/etc/nginx/sites-enabled/{}'.format(env.project_name)
if lexists(symlink_name):
local("sudo rm {}".format(symlink_name))
local('sudo ln -s {0} {1}'.format(absPathNginxConf, symlink_name))
def symlink_upstart():
absPathUpstartConf = os.path.join(env.project_path, "etc/upstart.conf")
if not lexists(absPathUpstartConf):
raise ValueError("we expect an upstart conf to exist")
symlink_name = '/etc/init/{}.conf'.format(env.project_name)
if lexists(symlink_name):
local("sudo rm {}".format(symlink_name))
local('sudo ln -s {0} {1}'.format(absPathUpstartConf, symlink_name))