Skip to content
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

Merged
merged 5 commits into from
Aug 25, 2023

Conversation

masenf
Copy link
Collaborator

@masenf masenf commented Aug 23, 2023

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.

REF-160

masenf added 2 commits August 23, 2023 09:56
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
@masenf masenf added this to the v0.2.7 milestone Aug 23, 2023
@Lendemor Lendemor mentioned this pull request Aug 24, 2023
11 tasks
Copy link
Contributor

@picklelo picklelo left a 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

Copy link
Contributor

@picklelo picklelo left a 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}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

@picklelo picklelo merged commit 3916668 into main Aug 25, 2023
@masenf masenf deleted the masenf/no-backend-compile branch August 29, 2023 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants