def deploy_ref(deployment_name, ref):
setup_env(deployment_name)
with cd(env.kc_path):
run("git fetch origin")
# Make sure we're not moving to an older codebase
git_output = run('git rev-list {}..HEAD --count 2>&1'.format(ref))
if int(git_output) > 0:
raise Exception("The server's HEAD is already in front of the "
"commit to be deployed.")
# We want to check out a specific commit, but this does leave the HEAD
# detached. Perhaps consider using `git reset`.
run('git checkout {}'.format(ref))
# Report if the working directory is unclean.
git_output = run('git status --porcelain')
if len(git_output):
run('git status')
print('WARNING: The working directory is unclean. See above.')
deploy_template(env)
run('find . -name "*.pyc" -exec rm -rf {} \;')
run('find . -type d -empty -delete')
# numpy pip install from requirements file fails
with kobo_workon(env.kc_virtualenv_name):
run("pip install numpy")
run("pip install --upgrade -r %s" % env.pip_requirements_file)
formpack_path = os.path.join(env.home, 'formpack')
formpack_branch = env.get('formpack_branch', False)
run("[ -d {fp} ] || git clone https://github.com/kobotoolbox/formpack.git "
"{fp}".format(fp=formpack_path))
with cd(formpack_path):
with kobo_workon(env.kc_virtualenv_name):
if formpack_branch:
run("git checkout {b} && git pull origin {b}"
.format(b=formpack_branch))
run("python setup.py develop")
with cd(os.path.join(env.kc_path, "onadata", "static")):
run("date > LAST_UPDATE.txt")
with cd(env.kc_path):
with kobo_workon(env.kc_virtualenv_name):
run("python manage.py syncdb")
run("python manage.py migrate")
run("python manage.py collectstatic --noinput")
run("sudo restart kc_celeryd")
run("sudo restart uwsgi")
评论列表
文章目录