mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-10 11:59:23 +00:00
Compile openapi client in background when django runserver is reloading
This commit is contained in:
@ -50,7 +50,13 @@ class Command(CollectStatic):
|
||||
return Path(location)
|
||||
|
||||
Scss.compile(self.collect_scss())
|
||||
OpenApi.compile() # This needs to be prior to javascript bundling
|
||||
openapi = OpenApi.compile() # This needs to be prior to javascript bundling
|
||||
if openapi is not None:
|
||||
_ = openapi.wait()
|
||||
if openapi.returncode:
|
||||
raise RuntimeError(
|
||||
f"Openapi generation failed with returncode {openapi.returncode}"
|
||||
)
|
||||
JSBundler.compile()
|
||||
|
||||
collected = super().collect()
|
||||
|
@ -15,11 +15,18 @@ class Command(Runserver):
|
||||
"""Light wrapper around default runserver that integrates javascirpt auto bundling."""
|
||||
|
||||
def run(self, **options):
|
||||
OpenApi.compile()
|
||||
if (
|
||||
os.environ.get(DJANGO_AUTORELOAD_ENV) is None
|
||||
and settings.PROCFILE_STATIC is not None
|
||||
):
|
||||
is_django_reload = os.environ.get(DJANGO_AUTORELOAD_ENV) is not None
|
||||
|
||||
proc = OpenApi.compile()
|
||||
# Ensure that the first runserver launch creates openapi files
|
||||
# before the bundler starts so that it detects them
|
||||
# When django is reloaded, we can keep this process in background
|
||||
# to reduce reload time
|
||||
if proc is not None and not is_django_reload:
|
||||
_ = proc.wait()
|
||||
|
||||
if not is_django_reload and settings.PROCFILE_STATIC is not None:
|
||||
start_composer(settings.PROCFILE_STATIC)
|
||||
_ = atexit.register(stop_composer, procfile=settings.PROCFILE_STATIC)
|
||||
|
||||
super().run(**options)
|
||||
|
Reference in New Issue
Block a user