Skip to content

Commit e16824f

Browse files
authoredNov 9, 2020
Merge pull request frappe#1094 from gavindsouza/compileall-here
fix: Run compileall in bench after update
2 parents 629b272 + 54e6bcf commit e16824f

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed
 

‎bench/commands/update.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515
@click.option('--restart-supervisor', is_flag=True, help="Restart supervisor processes after update")
1616
@click.option('--restart-systemd', is_flag=True, help="Restart systemd units after update")
1717
@click.option('--no-backup', is_flag=True, help="If this flag is set, sites won't be backed up prior to updates. Note: This is not recommended in production.")
18+
@click.option('--no-compile', is_flag=True, help="If set, Python bytecode won't be compiled before restarting the processes")
1819
@click.option('--force', is_flag=True, help="Forces major version upgrades")
1920
@click.option('--reset', is_flag=True, help="Hard resets git branch's to their new states overriding any changes and overriding rebase on pull")
20-
def update(pull, apps, patch, build, requirements, restart_supervisor, restart_systemd, no_backup, force, reset):
21+
def update(pull, apps, patch, build, requirements, restart_supervisor, restart_systemd, no_backup, no_compile, force, reset):
2122
from bench.utils import update
22-
update(pull=pull, apps=apps, patch=patch, build=build, requirements=requirements, restart_supervisor=restart_supervisor, restart_systemd=restart_systemd, backup=not no_backup, force=force, reset=reset)
23+
update(pull=pull, apps=apps, patch=patch, build=build, requirements=requirements, restart_supervisor=restart_supervisor, restart_systemd=restart_systemd, backup=not no_backup, compile=not no_compile, force=force, reset=reset)
2324

2425

2526
@click.command('retry-upgrade', help="Retry a failed upgrade")

‎bench/utils.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# -*- coding: utf-8 -*-
33

44
# imports - standard imports
5+
import compileall
56
import errno
67
import glob
78
import grp
@@ -183,8 +184,8 @@ def init(path, apps_path=None, no_procfile=False, no_backups=False,
183184
copy_patches_txt(path)
184185

185186

186-
def update(pull=False, apps=None, patch=False, build=False, requirements=False, backup=True, force=False, reset=False,
187-
restart_supervisor=False, restart_systemd=False):
187+
def update(pull=False, apps=None, patch=False, build=False, requirements=False, backup=True, compile=True,
188+
force=False, reset=False, restart_supervisor=False, restart_systemd=False):
188189
"""command: bench update"""
189190
from bench import patches
190191
from bench.app import is_version_upgrade, pull_apps, validate_branch
@@ -218,7 +219,6 @@ def update(pull=False, apps=None, patch=False, build=False, requirements=False,
218219

219220
if version_upgrade[0] or (not version_upgrade[0] and force):
220221
validate_upgrade(version_upgrade[1], version_upgrade[2], bench_path=bench_path)
221-
222222
conf.update({ "maintenance_mode": 1, "pause_scheduler": 1 })
223223
update_config(conf, bench_path=bench_path)
224224

@@ -246,6 +246,10 @@ def update(pull=False, apps=None, patch=False, build=False, requirements=False,
246246
if version_upgrade[0] or (not version_upgrade[0] and force):
247247
post_upgrade(version_upgrade[1], version_upgrade[2], bench_path=bench_path)
248248

249+
if pull and compile:
250+
print("Compiling Python files...")
251+
compileall.compile_dir('../apps', quiet=1, rx=re.compile('.*node_modules.*'))
252+
249253
if restart_supervisor or conf.get('restart_supervisor_on_update'):
250254
restart_supervisor_processes(bench_path=bench_path)
251255

@@ -481,7 +485,7 @@ def start(no_dev=False, concurrency=None, procfile=None, no_prefix=False):
481485

482486
if no_prefix:
483487
command.extend(['--no-prefix'])
484-
488+
485489
os.execv(program, command)
486490

487491

0 commit comments

Comments
 (0)
Please sign in to comment.