Skip to content

reload env file on hot reload in granian#5510

Merged
adhami3310 merged 1 commit into
mainfrom
reload-env-file-on-hot-reload-in-granian
Jun 30, 2025
Merged

reload env file on hot reload in granian#5510
adhami3310 merged 1 commit into
mainfrom
reload-env-file-on-hot-reload-in-granian

Conversation

@adhami3310
Copy link
Copy Markdown
Member

No description provided.

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

PR Summary

Added support for automatic environment variable reloading in Granian hot reload mode, improving developer experience by ensuring .env file changes are reflected without manual server restarts.

  • Added _reload_hook in reflex/utils/exec.py to handle environment reloading during Granian hot reload events
  • Moved dotenv loading logic from config.py to environment.py for better code organization
  • Added _load_dotenv_from_str and _load_dotenv_from_env in environment.py to handle colon-separated env file paths
  • Updated Granian dependency to >=2.4.0 in pyproject.toml to support new reload functionality

4 files reviewed, 1 comment
Edit PR Review Bot Settings | Greptile

Comment thread reflex/environment.py
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Jun 30, 2025

CodSpeed Performance Report

Merging #5510 will not alter performance

Comparing reload-env-file-on-hot-reload-in-granian (397460e) with main (5128f44)

Summary

✅ 8 untouched benchmarks

@adhami3310 adhami3310 merged commit e9c2e4b into main Jun 30, 2025
41 checks passed
@adhami3310 adhami3310 deleted the reload-env-file-on-hot-reload-in-granian branch June 30, 2025 18:17
@gi0baro
Copy link
Copy Markdown

gi0baro commented Jun 30, 2025

@adhami3310 it seems to me you can actually get rid of the hook and directly pass env_files to Granian constructor (with 2.4.0 it loads those files on reload both on the main process and in the workers when they start).

edit: see https://github.com/emmett-framework/granian/blob/v2.4.0/granian/server/common.py#L479

@adhami3310
Copy link
Copy Markdown
Member Author

@gi0baro that seems cleaner, i will look into it, thanks for the comment :D

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.

3 participants