-
[OPIK-2175] [SCRIPTS] Add BE-only mode to dev-runner script (#3525)
发布于
2025-10-02 14:29:41 +00:00 - [OPIK-2175] Add BE-only mode to dev-runner script
Add new development mode that runs backend as a local process while keeping
frontend and infrastructure in Docker containers using opik.sh --local-be mode.New commands:
- --be-only-start: Start infrastructure, Docker frontend, and backend process
- --be-only-stop: Stop backend process and Docker services
- --be-only-restart: Stop, build backend, and start all services
- --be-only-verify: Verify status of BE-only services
This mode is useful for backend development with hot-reload while using
the stable Docker frontend. All existing modes remain fully compatible.-
Revision 2: Use neutral wording for Docker service logs
-
Revision 3: Rename wrapper functions to use local-be naming convention
Renamed BE-only Docker service wrapper functions for clarity:
- start_infrastructure_and_docker_frontend -> start_local_be_docker_services
- stop_infrastructure_and_docker_frontend -> stop_local_be_docker_services
- verify_infrastructure_and_docker_frontend -> verify_local_be_docker_services
This naming better reflects the opik.sh --local-be mode being used.
- Revision 4: Refactor verification functions to eliminate duplication
Extract common functionality into helper functions:
- check_backend_process_status(): Check if backend process is running
- display_backend_process_status(): Display backend status with custom label
- show_access_information(): Display access info with configurable parameters
Updated verify_be_only_services to use helper functions with BE-only parameters:
- UI URL: http://localhost:5173 (Docker frontend port)
- SDK command: opik configure --use_local (no manual edit needed)
- Environment variable: OPIK_URL_OVERRIDE updated to match UI URL
- Removed mode/backend process details from output
This eliminates ~50 lines of duplicated code and improves maintainability.
- Revision 5: Merge backend process status check into display function
Simplified helper functions by merging check_backend_process_status into
display_backend_process_status since the check function was only used
internally and the split was unnecessary.This reduces code complexity while maintaining the same functionality.
- Revision 6: Simplify display_backend_process_status to remove label parameter
Removed the customizable label parameter from display_backend_process_status
and just hardcoded 'Backend' since the distinction between 'Backend' and
'Backend Process' was unnecessary complexity.Updated both call sites (verify_services and verify_be_only_services) to
call the function without parameters.- Revision 7: Encapsulate stop logic into unified stop_services function
Created stop_services() function that encapsulates the stop logic for
frontend, backend, and infrastructure with aligned logging format
matching stop_be_only_services().Changes:
- New stop_services() function with structured step-by-step logging
- Updated --stop case to call stop_services instead of inline calls
- Consistent logging format: '=== Stopping...', 'Step X/Y:', '=== Complete ==='
This makes the code more maintainable and provides better user feedback.
- Revision 8: Encapsulate migrate and unknown option handling into functions
Created two new functions for better code organization:
-
migrate_services():
- Encapsulates the --migrate logic
- Structured step-by-step logging format
- Consistent with other service management functions
-
handle_unknown_option():
- Encapsulates error handling for unknown options
- Maintains consistent error reporting pattern
- Single responsibility for option validation
Updated both --migrate and unknown option (*) cases to call their
respective functions, making the main script logic cleaner and more
maintainable.- Revision 9: Reorganize help output into logical categories
Moved build and maintenance commands from 'Standard Mode' into a new
'Build & Maintenance' category for better organization:- --build-be
- --build-fe
- --migrate
Updated categories:
- Standard Mode: Service management (start, stop, restart, verify)
- BE-Only Mode: BE-only service management
- Build & Maintenance: Build and migration commands
- Utility Options: Debug, logs, lint, help
Added new example showing build-be + migrate combination usage.
- Revision 10: Display suggested URL after SDK configure command for BE-only mode
When show_manual_edit is false (BE-only mode), display the suggested URL
that should be used when prompted by the opik configure command:When prompted, use URL: http://localhost:5173
This provides clearer guidance for users configuring the SDK in BE-only mode.
- Revision 11: Add /api suffix to OPIK_URL_OVERRIDE for BE-only mode
When showing the environment variable alternative for SDK configuration in
BE-only mode (no manual edit required), append /api to the URL:
export OPIK_URL_OVERRIDE='http://localhost:5173/api'This is required because the Docker frontend (nginx) routes /api requests
to the backend, so the SDK must use the /api path when connecting via the
frontend URL.- Revision 12: Always use "opik configure --use_local" in SDK configuration
Refactored show_access_information to always use "opik configure --use_local"
command instead of varying between "opik configure" and "opik configure --use_local".Changes:
- Removed configure_command parameter (was second arg, now unused)
- Hardcoded "opik configure --use_local" as the SDK configuration command
- Updated show_manual_edit parameter position from third to second arg
- Updated both call sites (verify_services and verify_be_only_services)
This simplifies the function and ensures consistent SDK configuration
instructions across both standard and BE-only modes.- Update scripts/dev-runner.sh
Co-authored-by: Copilot 175728472+Copilot@users.noreply.github.com
Co-authored-by: Copilot 175728472+Copilot@users.noreply.github.com
下载附件