Skip to content

[commands] wrap server into CLI#14

Merged
capcom6 merged 1 commit into
masterfrom
commands/wrap-into-cli
Apr 29, 2026
Merged

[commands] wrap server into CLI#14
capcom6 merged 1 commit into
masterfrom
commands/wrap-into-cli

Conversation

@capcom6
Copy link
Copy Markdown
Contributor

@capcom6 capcom6 commented Apr 29, 2026

Summary by CodeRabbit

  • Chores

    • Updated build dependencies to support the chosen CLI framework.
  • Refactor

    • Restructured application startup to use a command-line interface with improved graceful shutdown and clearer exit-code handling.
  • New Features

    • Added a CLI "serve" command to run the backend service (start/stop logged for visibility).

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 29, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 76feac6a-6f1f-4921-bbc9-35926ce31d81

📥 Commits

Reviewing files that changed from the base of the PR and between b8e7fbe and 536ccaa.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (3)
  • go.mod
  • internal/app.go
  • internal/commands/serve.go
✅ Files skipped from review due to trivial changes (2)
  • go.mod
  • internal/app.go

📝 Walkthrough

Walkthrough

Application startup is refactored to use urfave/cli. The FX initialization and lifecycle are moved into a new commands.Serve() function; the main entry now delegates to a CLI command, creating a cancellable context driven by SIGINT/SIGTERM and mapping CLI errors to exit codes.

Changes

Cohort / File(s) Summary
Dependency Addition
go.mod
Adds direct requirement on github.com/urfave/cli/v3 at v3.8.0.
CLI-based Entrypoint
internal/app.go
Replaces direct fx.New(...).Run() startup with a urfave/cli app exposing a backend serve command; sets up context cancellation on SIGINT/SIGTERM and maps CLI errors to process exit codes.
FX Serve Command
internal/commands/serve.go
New Serve(ctx context.Context, version healthfx.Version) error builds and runs an Uber FX application: registers infra modules (logger, bun, fiber, migrations, health, validation, MinIO), app modules (config, db, server, storage), business modules (JWT, users, projects, tasks, attachments, comments), injects version, attaches lifecycle hooks that log on start/stop, starts the app with timeouts, waits for ctx or app done, and stops the app with timeouts.

Sequence Diagram(s)

sequenceDiagram
    actor OS
    participant Main as Main
    participant CLI as "urfave/cli"
    participant Context as Context
    participant Serve as Serve()
    participant FX as "Uber FX App"
    participant Logger as "*zap.Logger"

    OS->>Main: Run(version)
    Main->>CLI: create CLI app + backend serve command
    Main->>Context: create cancellable context
    OS->>Main: register SIGINT/SIGTERM -> cancel Context
    CLI->>Serve: invoke serve action
    Serve->>FX: construct FX graph (modules + version)
    FX->>Logger: onStart hook -> log "app started"
    FX->>FX: Start with timeout
    Note over Context,FX: wait for Context cancel or FX done
    OS->>Context: signal -> cancel
    FX->>Logger: onStop hook -> log "app stopped"
    FX->>FX: Stop with timeout
    FX-->>Serve: return result
    Serve-->>CLI: return error/status
    CLI-->>Main: exit with code
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: refactoring the server startup to use a CLI wrapper with urfave/cli instead of direct FX module initialization.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 29, 2026

🤖 Pull request artifacts

Platform File
🐳 Docker GitHub Container Registry
🍎 Darwin arm64 backend_Darwin_arm64.tar.gz
🍎 Darwin x86_64 backend_Darwin_x86_64.tar.gz
🐧 Linux arm64 backend_Linux_arm64.tar.gz
🐧 Linux i386 backend_Linux_i386.tar.gz
🐧 Linux x86_64 backend_Linux_x86_64.tar.gz
🪟 Windows arm64 backend_Windows_arm64.zip
🪟 Windows i386 backend_Windows_i386.zip
🪟 Windows x86_64 backend_Windows_x86_64.zip

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@internal/commands/serve.go`:
- Around line 28-29: The Serve function currently starts the FX app with
fx.App.Run(), which prevents the outer CLI context from cancelling the app;
change Serve to accept a context.Context and return an error, instantiate the
fx.App as you do now but replace Run() with app.Start(ctx), then wait for
app.Done() (or app.Wait()) while monitoring ctx, and finally call app.Stop(ctx)
on cancellation or completion; update the caller in internal/app.go to call and
return commands.Serve(ctx, version) so the CLI context is propagated.
🪄 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: 1b0ce73f-f50a-4778-acf3-7bbd0f03f8fb

📥 Commits

Reviewing files that changed from the base of the PR and between 3253208 and b8e7fbe.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (3)
  • go.mod
  • internal/app.go
  • internal/commands/serve.go

Comment thread internal/commands/serve.go Outdated
Co-authored-by: Copilot <copilot@github.com>
@capcom6 capcom6 force-pushed the commands/wrap-into-cli branch from 64d2774 to 536ccaa Compare April 29, 2026 07:20
@capcom6 capcom6 merged commit 872741b into master Apr 29, 2026
6 of 7 checks passed
@capcom6 capcom6 deleted the commands/wrap-into-cli branch April 29, 2026 07: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.

1 participant