Added "preflight" worker

pull/334/head
Rui Carmo 2023-12-26 17:28:19 +00:00
rodzic 7eae80a795
commit 23159ddde8
2 zmienionych plików z 9 dodań i 0 usunięć

Wyświetl plik

@ -21,6 +21,7 @@ An app is simply a `git` repository with some additional files on the top level,
* `wsgi` workers, in the format `dotted.module:entry_point` (Python-only)
* `web` workers, which can be anything that honors the `PORT` environment variable
* `static` workers, which simply mount the first argument as the root static path
* `preflight` which is a special "worker" that is run once _before_ the app is deployed _and_ installing deps (can be useful for cleanups).
* `release` which is a special worker that is run once when the app is deployed, after installing deps (can be useful for build steps).
* `cron` workers, which require a simplified `cron` expression preceding the command to be run (e.g. `cron: */5 * * * * python batch.py` to run a batch every 5 minutes)
* `worker` processes, which are standalone workers and can have arbitrary names

Wyświetl plik

@ -385,6 +385,13 @@ def do_deploy(app, deltas={}, newrev=None):
workers = parse_procfile(procfile)
if workers and len(workers) > 0:
settings = {}
if "preflight" in workers:
echo("-----> Running preflight.", fg='green')
retval = call(workers["preflight"], cwd=app_path, env=settings, shell=True)
if retval:
echo("-----> Exiting due to preflight command error value: {}".format(retval))
exit(retval)
workers.pop("preflight", None)
if exists(join(app_path, 'requirements.txt')) and found_app("Python"):
settings.update(deploy_python(app, deltas))
elif exists(join(app_path, 'Gemfile')) and found_app("Ruby Application") and check_requirements(['ruby', 'gem', 'bundle']):
@ -687,6 +694,7 @@ def spawn_app(app, deltas={}):
app_path = join(APP_ROOT, app)
procfile = join(app_path, 'Procfile')
workers = parse_procfile(procfile)
workers.pop("preflight", None)
workers.pop("release", None)
ordinals = defaultdict(lambda: 1)
worker_count = {k: 1 for k in workers.keys()}