kopia lustrzana https://github.com/piku/piku
Move release worker to end of deploy. (#50)
* Move release worker to end of deploy. This matches up with what other PaaS platforms do. This change also makes the release worker inherit the environment (virtualenv etc.) from the deploy process, making it easier to run e.g. Django manage.py commands in the expected context without explicitly entering virtualenv in the script. * Update Django example to remove virtualenv. Now that this happens automatically we don't need to explicitly enter virtualenv in the script. * Pass spawn env back through to release worker. Conflicts: piku.pypull/54/head
rodzic
a4ded8c994
commit
b5daedb5bc
|
@ -1,8 +1,4 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
if [ -d "${ENV_ROOT}/bin" ]
|
./manage.py migrate --no-input
|
||||||
then
|
./manage.py collectstatic --no-input
|
||||||
. ${ENV_ROOT}/bin/activate
|
|
||||||
./manage.py migrate --no-input
|
|
||||||
./manage.py collectstatic --no-input
|
|
||||||
fi
|
|
||||||
|
|
42
piku.py
42
piku.py
|
@ -350,30 +350,28 @@ def do_deploy(app, deltas={}):
|
||||||
makedirs(log_path)
|
makedirs(log_path)
|
||||||
workers = parse_procfile(procfile)
|
workers = parse_procfile(procfile)
|
||||||
if workers and len(workers):
|
if workers and len(workers):
|
||||||
settings = parse_settings(env_file, env)
|
settings = {}
|
||||||
settings = parse_settings(config_file, settings)
|
if exists(join(app_path, 'requirements.txt')):
|
||||||
|
echo("-----> Python app detected.", fg='green')
|
||||||
|
settings.update(deploy_python(app, deltas))
|
||||||
|
elif exists(join(app_path, 'package.json')) and check_requirements(['nodejs', 'npm']):
|
||||||
|
echo("-----> Node app detected.", fg='green')
|
||||||
|
settings.update(deploy_node(app, deltas))
|
||||||
|
elif exists(join(app_path, 'pom.xml')) and check_requirements(['java', 'mvn']):
|
||||||
|
echo("-----> Java app detected.", fg='green')
|
||||||
|
settings.update(deploy_java(app, deltas))
|
||||||
|
elif (exists(join(app_path, 'Godeps')) or len(glob(join(app_path,'*.go')))) and check_requirements(['go']):
|
||||||
|
echo("-----> Go app detected.", fg='green')
|
||||||
|
settings.update(deploy_go(app, deltas))
|
||||||
|
else:
|
||||||
|
echo("-----> Could not detect runtime!", fg='red')
|
||||||
|
# TODO: detect other runtimes
|
||||||
if "release" in workers:
|
if "release" in workers:
|
||||||
echo("-----> Releasing", fg='green')
|
echo("-----> Releasing", fg='green')
|
||||||
settings["ENV_ROOT"] = join(ENV_ROOT, app)
|
|
||||||
retval = call(workers["release"], cwd=app_path, env=settings, shell=True)
|
retval = call(workers["release"], cwd=app_path, env=settings, shell=True)
|
||||||
if retval:
|
if retval:
|
||||||
exit(retval)
|
exit(retval)
|
||||||
workers.pop("release", None)
|
workers.pop("release", None)
|
||||||
if exists(join(app_path, 'requirements.txt')):
|
|
||||||
echo("-----> Python app detected.", fg='green')
|
|
||||||
deploy_python(app, deltas)
|
|
||||||
elif exists(join(app_path, 'package.json')) and check_requirements(['nodejs', 'npm']):
|
|
||||||
echo("-----> Node app detected.", fg='green')
|
|
||||||
deploy_node(app, deltas)
|
|
||||||
elif exists(join(app_path, 'pom.xml')) and check_requirements(['java', 'mvn']):
|
|
||||||
echo("-----> Java app detected.", fg='green')
|
|
||||||
deploy_java(app, deltas)
|
|
||||||
elif (exists(join(app_path, 'Godeps')) or len(glob(join(app_path,'*.go')))) and check_requirements(['go']):
|
|
||||||
echo("-----> Go app detected.", fg='green')
|
|
||||||
deploy_go(app, deltas)
|
|
||||||
else:
|
|
||||||
echo("-----> Could not detect runtime!", fg='red')
|
|
||||||
# TODO: detect other runtimes
|
|
||||||
else:
|
else:
|
||||||
echo("Error: Invalid Procfile for app '{}'.".format(app), fg='red')
|
echo("Error: Invalid Procfile for app '{}'.".format(app), fg='red')
|
||||||
else:
|
else:
|
||||||
|
@ -409,7 +407,7 @@ def deploy_go(app, deltas={}):
|
||||||
'GO15VENDOREXPERIMENT': '1'
|
'GO15VENDOREXPERIMENT': '1'
|
||||||
}
|
}
|
||||||
call('godep update ...', cwd=join(APP_ROOT, app), env=env, shell=True)
|
call('godep update ...', cwd=join(APP_ROOT, app), env=env, shell=True)
|
||||||
spawn_app(app, deltas)
|
return spawn_app(app, deltas)
|
||||||
|
|
||||||
|
|
||||||
def deploy_node(app, deltas={}):
|
def deploy_node(app, deltas={}):
|
||||||
|
@ -438,7 +436,7 @@ def deploy_node(app, deltas={}):
|
||||||
symlink(node_path, node_path_tmp)
|
symlink(node_path, node_path_tmp)
|
||||||
call('npm install', cwd=join(APP_ROOT, app), env=env, shell=True)
|
call('npm install', cwd=join(APP_ROOT, app), env=env, shell=True)
|
||||||
unlink(node_path_tmp)
|
unlink(node_path_tmp)
|
||||||
spawn_app(app, deltas)
|
return spawn_app(app, deltas)
|
||||||
|
|
||||||
|
|
||||||
def deploy_python(app, deltas={}):
|
def deploy_python(app, deltas={}):
|
||||||
|
@ -469,7 +467,7 @@ def deploy_python(app, deltas={}):
|
||||||
if first_time or getmtime(requirements) > getmtime(virtualenv_path):
|
if first_time or getmtime(requirements) > getmtime(virtualenv_path):
|
||||||
echo("-----> Running pip for '{}'".format(app), fg='green')
|
echo("-----> Running pip for '{}'".format(app), fg='green')
|
||||||
call('pip install -r {}'.format(requirements), cwd=virtualenv_path, shell=True)
|
call('pip install -r {}'.format(requirements), cwd=virtualenv_path, shell=True)
|
||||||
spawn_app(app, deltas)
|
return spawn_app(app, deltas)
|
||||||
|
|
||||||
|
|
||||||
def spawn_app(app, deltas={}):
|
def spawn_app(app, deltas={}):
|
||||||
|
@ -682,6 +680,8 @@ def spawn_app(app, deltas={}):
|
||||||
if exists(enabled):
|
if exists(enabled):
|
||||||
echo("-----> terminating '{app:s}:{k:s}.{w:d}'".format(**locals()), fg='yellow')
|
echo("-----> terminating '{app:s}:{k:s}.{w:d}'".format(**locals()), fg='yellow')
|
||||||
unlink(enabled)
|
unlink(enabled)
|
||||||
|
|
||||||
|
return env
|
||||||
|
|
||||||
|
|
||||||
def spawn_worker(app, kind, command, env, ordinal=1):
|
def spawn_worker(app, kind, command, env, ordinal=1):
|
||||||
|
|
Ładowanie…
Reference in New Issue