-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid compile step when running production backend #1665
Conversation
When executing `reflex run --env prod`, set `REFLEX_SKIP_COMPILE=yes` and then during `App.compile`, exit early if this env var is set. This avoids running the compile needlessly, since the prod backend does NOT use the compiled output for anything. In DEV mode, we must keep the compile step, because uvicorn re-importing the app module and triggering the compile on the backend is what triggers the NextJS frontend to rebuild.
the db commands never need to compile the app
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somehow this is still compiling when I run reflex run --env prod --backend-only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reason we can't apply this to backend only in dev mode also?
Also, should we print a message similar to "Your backend is running at <backend_url>"?
We can add those in a follow up if necessary.
uvicorn.run( | ||
app=f"{app_name}:{constants.APP_VAR}.{constants.API_VAR}", | ||
app=f"{app_module}.{constants.API_VAR}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
When executing
reflex run --env prod
, setREFLEX_SKIP_COMPILE=yes
and then duringApp.compile
, exit early if this env var is set. This avoids running the compile needlessly, since the prod backend does NOT use the compiled output for anything.In DEV mode, we must keep the compile step, because uvicorn re-importing the app module and triggering the compile on the backend is what triggers the NextJS frontend to rebuild.
REF-160