set env mode before importing modules that contain rx.State subclasses
This commit is contained in:
parent
f94328f74f
commit
6ce9471e6f
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
# WARNING: do not import any modules that contain rx.State subclasses here
|
||||||
import atexit
|
import atexit
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@ -15,7 +16,6 @@ from reflex_cli.utils import dependency
|
|||||||
from reflex import constants
|
from reflex import constants
|
||||||
from reflex.config import EnvironmentVariables, get_config
|
from reflex.config import EnvironmentVariables, get_config
|
||||||
from reflex.custom_components.custom_components import custom_components_cli
|
from reflex.custom_components.custom_components import custom_components_cli
|
||||||
from reflex.state import reset_disk_state_manager
|
|
||||||
from reflex.utils import console, redir, telemetry
|
from reflex.utils import console, redir, telemetry
|
||||||
|
|
||||||
# Disable typer+rich integration for help panels
|
# Disable typer+rich integration for help panels
|
||||||
@ -154,14 +154,17 @@ def _run(
|
|||||||
loglevel: constants.LogLevel = config.loglevel,
|
loglevel: constants.LogLevel = config.loglevel,
|
||||||
):
|
):
|
||||||
"""Run the app in the given directory."""
|
"""Run the app in the given directory."""
|
||||||
|
|
||||||
|
# Set env mode in the environment
|
||||||
|
# This must be set before importing modules that contain rx.State subclasses
|
||||||
|
EnvironmentVariables.REFLEX_ENV_MODE.set(env)
|
||||||
|
|
||||||
|
from reflex.state import reset_disk_state_manager
|
||||||
from reflex.utils import build, exec, prerequisites, processes
|
from reflex.utils import build, exec, prerequisites, processes
|
||||||
|
|
||||||
# Set the log level.
|
# Set the log level.
|
||||||
console.set_log_level(loglevel)
|
console.set_log_level(loglevel)
|
||||||
|
|
||||||
# Set env mode in the environment
|
|
||||||
EnvironmentVariables.REFLEX_ENV_MODE.set(env)
|
|
||||||
|
|
||||||
# Show system info
|
# Show system info
|
||||||
exec.output_system_info()
|
exec.output_system_info()
|
||||||
|
|
||||||
@ -304,7 +307,6 @@ def run(
|
|||||||
raise typer.Exit(1)
|
raise typer.Exit(1)
|
||||||
EnvironmentVariables.REFLEX_BACKEND_ONLY.set(backend)
|
EnvironmentVariables.REFLEX_BACKEND_ONLY.set(backend)
|
||||||
EnvironmentVariables.REFLEX_FRONTEND_ONLY.set(frontend)
|
EnvironmentVariables.REFLEX_FRONTEND_ONLY.set(frontend)
|
||||||
EnvironmentVariables.REFLEX_ENV_MODE.set(env)
|
|
||||||
|
|
||||||
_run(env, frontend, backend, frontend_port, backend_port, backend_host, loglevel)
|
_run(env, frontend, backend, frontend_port, backend_port, backend_host, loglevel)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user