2025-03-04 14:48:44 +01:00
|
|
|
import atexit
|
|
|
|
import os
|
|
|
|
|
|
|
|
from django.conf import settings
|
2024-09-17 23:42:05 +02:00
|
|
|
from django.contrib.staticfiles.management.commands.runserver import (
|
|
|
|
Command as Runserver,
|
|
|
|
)
|
2025-03-04 14:48:44 +01:00
|
|
|
from django.utils.autoreload import DJANGO_AUTORELOAD_ENV
|
2024-09-17 23:42:05 +02:00
|
|
|
|
2025-03-04 14:48:44 +01:00
|
|
|
from sith.composer import start_composer, stop_composer
|
2025-02-15 12:15:08 +01:00
|
|
|
from staticfiles.processors import OpenApi
|
2024-09-17 23:42:05 +02:00
|
|
|
|
|
|
|
|
|
|
|
class Command(Runserver):
|
2024-11-18 15:36:05 +01:00
|
|
|
"""Light wrapper around default runserver that integrates javascirpt auto bundling."""
|
2024-09-17 23:42:05 +02:00
|
|
|
|
|
|
|
def run(self, **options):
|
2024-10-09 16:28:54 +02:00
|
|
|
OpenApi.compile()
|
2025-03-04 14:48:44 +01:00
|
|
|
if (
|
|
|
|
os.environ.get(DJANGO_AUTORELOAD_ENV) is None
|
|
|
|
and settings.PROCFILE_STATIC is not None
|
|
|
|
):
|
|
|
|
start_composer(settings.PROCFILE_STATIC)
|
|
|
|
_ = atexit.register(stop_composer, procfile=settings.PROCFILE_STATIC)
|
2024-09-17 23:42:05 +02:00
|
|
|
super().run(**options)
|