SurfSense
SurfSense copied to clipboard
Feature: Uvicorn Config on .env
Description
Related to #159, made uvicorn configuration via .env. Initially I thought a simple proxy flag would be sufficient. But after some thought, I decided to just make the entire uvicorn configuration part of the .env since it should be more extensible compared to arguments. Hopefully the implementation is acceptable. Might need a bit of an adjustment in the documentation.
Also, I didn't make the proxy mode always on (the solution of the issue) since obviously everyone's deployment differs from one another.
Motivation and Context
Configuration without the need to change the source code. Should make deployment easier.
Changes Overview
Added lots of environment variable to configure uvicorn.
API Changes
- [ ] This PR includes API changes
Types of changes
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Performance improvement (non-breaking change which enhances performance)
- [ ] Documentation update
- [x] Breaking change (fix or feature that would cause existing functionality to change)
Testing
- [x] I have tested these changes locally
- [ ] I have added/updated unit tests
- [ ] I have added/updated integration tests
Checklist:
- [x] My code follows the code style of this project
- [x] My change requires documentation updates
- [ ] I have updated the documentation accordingly
- [ ] My change requires dependency updates
- [ ] I have updated the dependencies accordingly
- [x] My code builds clean without any errors or warnings
- [x] All new and existing tests passed
What do you think about this solution for the configuration? This puts too many variables on the .env, A possibly better alternative is to use uvicorn to run it with uvicorn config and cli. But that solution changes the flow of the program in case other executions are necessary aside from the uvicorn.
Let me know whether this is good or not!
Summary by CodeRabbit
Summary by CodeRabbit
- New Features
- Added support for configuring Uvicorn server settings via environment variables, including advanced options for customization.
- Chores
- Improved formatting and documentation in the environment variable example file for clarity and consistency.
- Refactor
- Centralized Uvicorn server configuration loading for easier environment-driven setup and maintenance.
@MuhamadAjiW is attempting to deploy a commit to the Rohan Verma's projects Team on Vercel.
A member of the Team first needs to authorize it.
Walkthrough
The changes introduce a new utility to load Uvicorn server configuration from environment variables, update the .env.example file with new Uvicorn-related options, and refactor the main application entry point to use the new configuration loader. Additionally, documentation was extended with detailed Uvicorn environment variable descriptions. No functional code outside configuration and startup logic was altered.
Changes
| File(s) | Change Summary |
|---|---|
| surfsense_backend/.env.example | Updated formatting and added Uvicorn server configuration options with comments and defaults. |
| surfsense_backend/app/config/uvicorn.py | Added new module with load_uvicorn_config to parse Uvicorn config from environment/CLI arguments. |
| surfsense_backend/main.py | Refactored startup logic to use load_dotenv and load_uvicorn_config for Uvicorn server launch. |
| surfsense_web/content/docs/docker-installation.mdx, surfsense_web/content/docs/manual-installation.mdx | Added new sections documenting Uvicorn server environment variables and configuration details. |
Sequence Diagram(s)
sequenceDiagram
participant CLI_User
participant MainApp
participant EnvLoader
participant UvicornConfigLoader
participant UvicornServer
CLI_User->>MainApp: Run main.py with CLI args
MainApp->>EnvLoader: load_dotenv()
MainApp->>UvicornConfigLoader: load_uvicorn_config(args)
UvicornConfigLoader->>EnvLoader: Read environment variables
UvicornConfigLoader-->>MainApp: Return config dict
MainApp->>UvicornServer: Instantiate with config
MainApp->>UvicornServer: server.run()
Poem
A rabbit hops to new config ground,
Uvicorn settings now abound!
From env to code, the values flow,
With comments clear, so all may know.
Startup’s neat, refactored right—
The server’s ready, day or night!
🐇✨
📜 Recent review details
Configuration used: CodeRabbit UI Review profile: CHILL Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 3022e448030e824d391c2028810cc4f3d68ea050 and d23541ee4412db1e6504fc8ea205528a898cff0a.
📒 Files selected for processing (2)
surfsense_web/content/docs/docker-installation.mdx(1 hunks)surfsense_web/content/docs/manual-installation.mdx(1 hunks)
✅ Files skipped from review due to trivial changes (2)
- surfsense_web/content/docs/docker-installation.mdx
- surfsense_web/content/docs/manual-installation.mdx
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Explain this complex logic.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai explain this code block.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and explain its main purpose.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
✨ No issues found! Your code is sparkling clean! ✨
Nice Work @MuhamadAjiW 🥇 Can you also update this change in docs : https://github.com/MODSetter/SurfSense/tree/main/surfsense_web/content/docs 👍
Nice Work @MuhamadAjiW 🥇 Can you also update this change in docs : https://github.com/MODSetter/SurfSense/tree/main/surfsense_web/content/docs 👍
Done! Is it enough?
Nice Work @MuhamadAjiW 🥇 Can you also update this change in docs : https://github.com/MODSetter/SurfSense/tree/main/surfsense_web/content/docs 👍
Done! Is it enough?
Nice Job. Great Work. Thanks :)