Skip to content

Commit

Permalink
feat: add more flexibility to procfile render
Browse files Browse the repository at this point in the history
  • Loading branch information
blaggacao committed Nov 27, 2024
1 parent 0bb5ffe commit ac08ec6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
13 changes: 9 additions & 4 deletions bench/config/procfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
import click

import bench
from bench.app import use_rq
from bench.bench import Bench
from bench.utils import which


def setup_procfile(bench_path, yes=False, skip_redis=False):
def setup_procfile(bench_path, yes=False, skip_redis=False, skip_web=False, skip_watch=None, skip_socketio=False, skip_schedule=False, with_coverage=False):
if skip_watch is None:
# backwards compatibilty; may be eventually removed
skip_watch = os.environ.get("CI")
config = Bench(bench_path).conf
procfile_path = os.path.join(bench_path, "Procfile")

Expand All @@ -25,10 +27,13 @@ def setup_procfile(bench_path, yes=False, skip_redis=False):
.get_template("Procfile")
.render(
node=which("node") or which("nodejs"),
use_rq=use_rq(bench_path),
webserver_port=config.get("webserver_port"),
CI=os.environ.get("CI"),
skip_redis=skip_redis,
skip_web=skip_web,
skip_watch=skip_watch,
skip_socketio=skip_socketio,
skip_schedule=skip_schedule,
with_coverage=with_coverage,
workers=config.get("workers", {}),
is_mac=is_mac,
)
Expand Down
13 changes: 8 additions & 5 deletions bench/config/templates/Procfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@
redis_cache: redis-server config/redis_cache.conf
redis_queue: redis-server config/redis_queue.conf
{% endif %}
web: bench serve {% if webserver_port -%} --port {{ webserver_port }} {%- endif %}

{% if not skip_web %}
web: bench serve {% if with_coverage -%} --with-coverage {%- endif %} {% if webserver_port -%} --port {{ webserver_port }} {%- endif %}
{% endif %}
{% if not skip_socketio %}
socketio: {{ node }} apps/frappe/socketio.js

{% if not CI %}
{% endif %}
{% if not skip_watch %}
watch: bench watch
{% endif %}

{% if not skip_schedule %}
schedule: bench schedule
{% endif %}
worker: {{ 'OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES NO_PROXY=*' if is_mac else '' }} bench worker 1>> logs/worker.log 2>> logs/worker.error.log
{% for worker_name, worker_details in workers.items() %}
worker_{{ worker_name }}: {{ 'OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES NO_PROXY=*' if is_mac else '' }} bench worker --queue {{ worker_name }} 1>> logs/worker.log 2>> logs/worker.error.log
Expand Down

0 comments on commit ac08ec6

Please sign in to comment.