Menu
Introduction
Getting Started
Developer guide
Release
Architecture
CLI
Technical documentations
Version
Publication date

Mar 9, 2022

Confidentiality
Public
Reactions
1
Share

ReflexProcess

Object representing a running Reflex app process. This process runs the front and back of a Reflex app. In dev mode: runs 'reflex run'. In prod mode: builds frontend (served by nginx) and runs backend-only.

There is 1 ReflexProcess per app. If the same reflex app is runned multiple times, it will use the different processes. In prod the front build folder is stored in resource path.

Attributes
back_port: intfront_port: int
Functions
__init__

Initialize the app process.

Note: The app is not generated here. Generation happens on first start.

front_port : int
back_port : int
app : AppInstance
call_health_check

Call the health check of the app to check if it is still running

Return type : bool
count_connections
Return type : int
get_app_full_url

Get the full URL for the app with authentication tokens.

This method handles user authentication and generates access tokens.

Return type : AppInstanceUrl
get_back_host_url
Return type : str
get_current_user_theme
Return type : FrontTheme
get_custom_host_name

Get the custom-subdomain-based host name, or None when no custom subdomain applies.

Returns None in dev mode (the custom subdomain is ignored) or when the app has no custom subdomain set. Uses the same local/prod formatting as get_host_name, only the middle segment differs (custom subdomain instead of resource model id).

suffix : str - ''
Return type : str | None
get_custom_host_url

Get the full custom-subdomain URL (scheme + host + port), or None when not set.

suffix : str - ''
Return type : str | None
get_front_server_names

Get the list of host names the front nginx block should answer to.

Always contains the canonical id-based host, plus the custom-subdomain host as an alias when one is set. nginx routes by server_name, so listing both names on a single server block makes the custom host resolve to the same backend as the id host.

suffix : str - ''
Return type : list
get_host_name

Get the canonical host name for the app process based on the suffix. This is used to generate the host URL for the app.

We use the resource_model_id as host name to have a stable URL for the app. The stable URL is required for reflex as the backend url is stored in the front build and should not change at each deployment. In dev mode the DEV_MODE_APP_ID is used.

An app can optionally define a custom subdomain (see get_custom_host_name). The custom host is registered as an alias on the front nginx block — it never replaces this canonical host, so URLs and baked backend addresses stay stable.

suffix : str - ''
Return type : str
get_host_url
suffix : str - ''
Return type : str
get_id
Return type : str
get_ports

Return all local ports this process will bind to.

Return type : list
get_service_source_port
Return type : int
get_status

Get the current status of the app process

Return type : AppProcessStatus
get_status_dto
Return type : AppProcessStatusDTO
get_status_text

Get the current status text of the app process

Return type : str
get_token

Get the token of the app process. This is used to secure the app and allow access to it.

Return type : str
get_user_id_from_token

Get the user id from the user access token. If the user does not exist, return None.

user_access_token : str
The user access token
Return type : str | None
get_working_dir

Get the working directory for this app process.

The directory is created when the app is first started. Raises an exception if called before the app is generated.

Return type : str
is_running

Check if the app process is running

Return type : bool
is_starting

Check if the app process is starting

Return type : bool
is_stopped

Check if the app process is stopped

Return type : bool
set_status

Set the status and status text of the app process

status : AppProcessStatus
status_text : str - ''
set_stop_policy

Update the stop policy on the underlying app instance.

stop_policy : AppStopPolicy
start_app_async

Start the process for the app.

The app will be generated on first start if not already done.

start_check_running

Method to start the check running loop to check if the app is still used

stop_process

Kill the process and the app

subprocess_is_running
Return type : bool
update_custom_subdomain

Update the custom subdomain on a (possibly running) app process.

Updates the in-memory app instance and, if the process is running, re-registers its front nginx service(s) so the custom host alias is added/removed live (with an nginx reload). The canonical id-based host is untouched, so the running app keeps serving without interruption. When the process is not running, nothing else is needed: the host is rebuilt from the persisted value on the next start.

subdomain : str | None
user_has_access_to_app

Return the user id from the user access token if the user has access to the app.

user_access_token : str
The user access token
Return type : str | None
uses_port

Check if the process uses the given port

port : int
Return type : bool
wait_for_start

Wait for the process to start

Return type : AppProcessStatus
wait_main_app_health_check
Shine Logo
Technical bricks to reuse or customize

Have you developed a brick?

Share it to accelerate projects for the entire community.