Repository navigation
Go: add more start server parameters - #16093
Conversation
Signed-off-by: Jin Hai <[email protected]>
📝 WalkthroughWalkthroughBoth server entry points ( CLI flag expansions and logging control
Ingestor build and runtime integration
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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. Comment |
Signed-off-by: Jin Hai <[email protected]>
Signed-off-by: Jin Hai <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
internal/admin/service.go (1)
1842-1842: 💤 Low valueConsider clarifying the log message for the existing-admin branch.
This log message appears in the branch where the default superuser already exists (lines 1818-1840), and the code only ensures the tenant exists rather than initializing a new user. A message like
"Default super user verified successfully"or"Default super user and tenant initialized successfully"would more accurately reflect what's happening in this branch.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/admin/service.go` at line 1842, The log message in the common.Info call at line 1842 uses "Init default super user successfully" which is misleading because this log statement is in the code branch where the default superuser already exists (verified in the preceding conditional logic). Update the message to more accurately reflect what is actually happening in this branch, such as "Default super user verified successfully" or "Default super user and tenant initialized successfully", to clarify that the code is verifying an existing user and ensuring the tenant exists rather than initializing a new superuser.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cmd/admin_server.go`:
- Around line 146-152: The change to conditionally call InitDefaultAdmin() only
when the --init-superuser flag is set represents a breaking change from the
previous behavior where this initialization happened unconditionally. Document
this breaking change by adding clear comments in the initSuperuser conditional
block explaining why InitDefaultAdmin() is now behind a flag, and ensure release
notes or migration guides clearly explain that users relying on automatic admin
initialization on first startup must now explicitly pass the --init-superuser
flag to maintain the same behavior.
- Around line 70-74: In the versionFlag handling block, replace the os.Exit(0)
call with return instead. This improves consistency with the same version flag
handling in the other binary, makes the code more testable, and follows a
cleaner pattern for early function exits.
---
Nitpick comments:
In `@internal/admin/service.go`:
- Line 1842: The log message in the common.Info call at line 1842 uses "Init
default super user successfully" which is misleading because this log statement
is in the code branch where the default superuser already exists (verified in
the preceding conditional logic). Update the message to more accurately reflect
what is actually happening in this branch, such as "Default super user verified
successfully" or "Default super user and tenant initialized successfully", to
clarify that the code is verifying an existing user and ensuring the tenant
exists rather than initializing a new superuser.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2637706a-f148-4633-bd4c-d3ff2f10b33e
📒 Files selected for processing (3)
cmd/admin_server.gocmd/server_main.gointernal/admin/service.go
| if initSuperuser { | ||
| // Initialize default admin user | ||
| if err := adminService.InitDefaultAdmin(); err != nil { | ||
| common.Error("Failed to initialize default admin user", err) | ||
| } | ||
|
|
||
| } |
There was a problem hiding this comment.
Document the breaking change in default admin initialization behavior.
The --init-superuser flag changes the default behavior: InitDefaultAdmin() is now only called when the flag is set, whereas it was previously called unconditionally. Deployments that rely on automatic admin initialization on first startup will need to explicitly pass --init-superuser.
While this change aligns with the PR objectives, ensure it's clearly documented in release notes or migration guides to prevent unexpected behavior for existing users.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@cmd/admin_server.go` around lines 146 - 152, The change to conditionally call
InitDefaultAdmin() only when the --init-superuser flag is set represents a
breaking change from the previous behavior where this initialization happened
unconditionally. Document this breaking change by adding clear comments in the
initSuperuser conditional block explaining why InitDefaultAdmin() is now behind
a flag, and ensure release notes or migration guides clearly explain that users
relying on automatic admin initialization on first startup must now explicitly
pass the --init-superuser flag to maintain the same behavior.
Signed-off-by: Jin Hai <[email protected]>
Signed-off-by: Jin Hai <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@build.sh`:
- Around line 341-345: The trap handler being set for INGESTOR_PID at line 344
replaces the earlier trap handler for ADMIN_PID instead of adding to it, causing
the admin_server process to leak and remain running after script exit. Modify
the trap command to clean up both ADMIN_PID and INGESTOR_PID processes together
in a single trap handler that catches the EXIT INT TERM signals. This can be
done by either combining both kill commands into the existing trap statement or
by appending to the existing trap using the trap -p command to retrieve and
merge the previous trap behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 17991ac5-c206-42d3-8473-66591a077406
📒 Files selected for processing (3)
build.shcmd/admin_server.gocmd/ingestor.go
🚧 Files skipped from review as they are similar to previous changes (1)
- cmd/admin_server.go
| print_section "Starting ingestor (background)" | ||
| "$INGESTOR_BINARY" & | ||
| INGESTOR_PID=$! | ||
| trap 'kill "$INGESTOR_PID" 2>/dev/null || true' EXIT INT TERM | ||
| sleep 1 |
There was a problem hiding this comment.
Trap handler override leaks admin_server on exit.
The trap at Line 344 replaces the earlier trap for ADMIN_PID, so only ingestor is cleaned up and admin_server can remain running after script exit.
Suggested fix
- "$ADMIN_SERVER_BINARY" &
- ADMIN_PID=$!
- trap 'kill "$ADMIN_PID" 2>/dev/null || true' EXIT INT TERM
+ "$ADMIN_SERVER_BINARY" &
+ ADMIN_PID=$!
@@
"$INGESTOR_BINARY" &
INGESTOR_PID=$!
- trap 'kill "$INGESTOR_PID" 2>/dev/null || true' EXIT INT TERM
+ cleanup() {
+ kill "$INGESTOR_PID" 2>/dev/null || true
+ kill "$ADMIN_PID" 2>/dev/null || true
+ }
+ trap cleanup EXIT INT TERM
sleep 1🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@build.sh` around lines 341 - 345, The trap handler being set for INGESTOR_PID
at line 344 replaces the earlier trap handler for ADMIN_PID instead of adding to
it, causing the admin_server process to leak and remain running after script
exit. Modify the trap command to clean up both ADMIN_PID and INGESTOR_PID
processes together in a single trap handler that catches the EXIT INT TERM
signals. This can be done by either combining both kill commands into the
existing trap statement or by appending to the existing trap using the trap -p
command to retrieve and merge the previous trap behavior.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #16093 +/- ##
=======================================
Coverage 93.16% 93.16%
=======================================
Files 10 10
Lines 717 717
Branches 118 118
=======================================
Hits 668 668
Misses 29 29
Partials 20 20 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
### What problem does this PR solve? ``` $ ./bin/ragflow_server --version RAGFlow version: v0.26.0-65-g549f6109c $ ./bin/ragflow_server --debug # start server with debug log level $ ./bin/admin_server --version RAGFlow version: v0.26.0-65-g549f6109c $ ./bin/admin_server --debug # start server with debug log level $ ./bin/admin_server --init-superuser # init default superuser $ ./bin/ingestor --version RAGFlow version: v0.26.0-68-g6f6c39706 $ ./bin/ingestor --debug ``` ### Type of change - [x] New Feature (non-breaking change which adds functionality) --------- Signed-off-by: Jin Hai <[email protected]>
What problem does this PR solve?
Type of change