mirror of
https://github.com/frappe/bench.git
synced 2025-02-03 03:18:24 +00:00
153546afd7
Goals: - Commonify bench operations in a way that intuitive - Get rid of the multiple duplicate functions because it's so hard to understand flow in the codebase ;) - Eliminate the need to guess, re-guess and pass bench info in each function that needs to do literally anything - Increase my happiness index because I just realised that I'm the top contributor of this project and I'd like to make it my own. - Adopt the principles of Least Surprise & The Principle of The Bigger Smile (of DHH) [inspired by ruby & ror] Changes: - The bench module has Bench and the action classes that can be accessed through the bench object - Used the Bench class to access properties like sites, apps & run (to execute commands in context) to reduce effort and clutter - Style improvements & minor changes included
31 lines
854 B
Python
Executable File
31 lines
854 B
Python
Executable File
# imports - standard imports
|
|
import os
|
|
|
|
# imports - third party imports
|
|
import click
|
|
|
|
# imports - module imports
|
|
import bench
|
|
from bench.app import use_rq
|
|
from bench.utils import which
|
|
from bench.bench import Bench
|
|
|
|
|
|
def setup_procfile(bench_path, yes=False, skip_redis=False):
|
|
config = Bench(bench_path).conf
|
|
procfile_path = os.path.join(bench_path, 'Procfile')
|
|
if not yes and os.path.exists(procfile_path):
|
|
click.confirm('A Procfile already exists and this will overwrite it. Do you want to continue?',
|
|
abort=True)
|
|
|
|
procfile = bench.config.env().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,
|
|
workers=config.get("workers", {}))
|
|
|
|
with open(procfile_path, 'w') as f:
|
|
f.write(procfile)
|