docs: update service management API completion report
- Add issue found & fixed section - Document route conflict problem and solution - Clarify public vs protected endpoints - Add authentication requirements for frontend - Update version to 1.1
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Service Management API Complete
|
||||
version: 1.0
|
||||
version: 1.1
|
||||
date: 2026-10-24
|
||||
author: OpenCode
|
||||
status: complete
|
||||
@@ -12,20 +12,34 @@ Enable MarkBaseEngine management UI (Stop/Start/Test buttons) to control inferen
|
||||
## Summary
|
||||
Successfully implemented service management API for controlling llama.cpp VLM service. All endpoints are working correctly and tested.
|
||||
|
||||
**Update (2026-10-24 03:50)**: Fixed route conflict issue. Service management API now fully operational.
|
||||
|
||||
## Issue Found & Fixed
|
||||
|
||||
### Problem
|
||||
- `/api/v1/mbe/health` was returning 401 Unauthorized
|
||||
- Root cause: `health::health_routes()` was conflicting with `public_health_routes`
|
||||
- `health::health_routes()` defines routes without `/api/v1` prefix, causing routing conflicts
|
||||
|
||||
### Solution
|
||||
- Removed duplicate `health::health_routes()` merge from app router
|
||||
- `public_health_routes` already contains all health endpoints with correct `/api/v1` prefix
|
||||
- Moved `service_management::router()` to `protected_routes` for proper authentication
|
||||
|
||||
## Implementation Details
|
||||
|
||||
### New API Endpoints
|
||||
|
||||
| Endpoint | Method | Purpose | Status |
|
||||
|----------|--------|---------|--------|
|
||||
| `/api/v1/mbe/health` | GET | Check VLM service status | ✅ Working |
|
||||
| `/api/v2/service/start` | POST | Start llama-server | ✅ Working |
|
||||
| `/api/v2/service/stop` | POST | Stop llama-server | ✅ Working |
|
||||
| Endpoint | Method | Purpose | Auth | Status |
|
||||
|----------|--------|---------|------|--------|
|
||||
| `/api/v1/mbe/health` | GET | Check VLM service status | Public | ✅ Working |
|
||||
| `/api/v2/service/start` | POST | Start llama-server | Required | ✅ Working |
|
||||
| `/api/v2/service/stop` | POST | Stop llama-server | Required | ✅ Working |
|
||||
|
||||
### Files Changed
|
||||
- `src/api/service_management.rs`: New module with all handlers (start_service, stop_service, mbe_health)
|
||||
- `src/api/mod.rs`: Module declaration
|
||||
- `src/api/server.rs`: Router integration with public routes
|
||||
- `src/api/server.rs`: Router integration, fixed route conflict
|
||||
|
||||
### Key Technical Decisions
|
||||
|
||||
@@ -45,23 +59,27 @@ Successfully implemented service management API for controlling llama.cpp VLM se
|
||||
- Extracts model name from response
|
||||
- Returns "offline" if port not in use or HTTP request fails
|
||||
|
||||
5. **Route Organization**:
|
||||
- Public routes (no auth): `/api/v1/health/*`, `/api/v1/mbe/health`
|
||||
- Protected routes (auth required): `/api/v2/service/*`
|
||||
|
||||
### Testing Results
|
||||
|
||||
```bash
|
||||
# Health check (service running)
|
||||
# Health check (public, no auth required)
|
||||
GET /api/v1/mbe/health
|
||||
Response: {"status":"ok","model":"gemma-4-12b-it-Q4_K_M.gguf","uptime":0}
|
||||
|
||||
# Health check (service stopped)
|
||||
Response: {"status":"offline"}
|
||||
|
||||
# Stop service
|
||||
POST /api/v2/service/stop {"name":"mbe"}
|
||||
Response: {"result":"stopped"}
|
||||
# Stop service (requires API key)
|
||||
POST /api/v2/service/start?api_key=... {"name":"mbe"}
|
||||
Response: {"result":"started","pid":14151}
|
||||
|
||||
# Start service
|
||||
POST /api/v2/service/start {"name":"mbe"}
|
||||
Response: {"result":"started","pid":72415}
|
||||
# Start service (requires API key)
|
||||
POST /api/v2/service/stop?api_key=... {"name":"mbe"}
|
||||
Response: {"result":"stopped"}
|
||||
```
|
||||
|
||||
### VLM Verification
|
||||
@@ -77,9 +95,9 @@ The endpoints match the expected API format in Momentry Studio (`AdminView.vue`)
|
||||
|
||||
```typescript
|
||||
// Studio expects these endpoints:
|
||||
start_service: `/api/v2/service/start` ✅ Implemented
|
||||
stop_service: `/api/v2/service/stop` ✅ Implemented
|
||||
mbe_health: `/api/v1/mbe/health` ✅ Implemented
|
||||
start_service: `/api/v2/service/start` ✅ Implemented (protected)
|
||||
stop_service: `/api/v2/service/stop` ✅ Implemented (protected)
|
||||
mbe_health: `/api/v1/mbe/health` ✅ Implemented (public)
|
||||
```
|
||||
|
||||
## Next Steps for Studio Team
|
||||
@@ -90,8 +108,12 @@ mbe_health: `/api/v1/mbe/health` ✅ Implemented
|
||||
- Stop button: Stops llama-server, status changes to "offline"
|
||||
- Start button: Starts llama-server, status changes to "online"
|
||||
- Test button: Sends test request to VLM
|
||||
3. **Authentication**:
|
||||
- `/api/v1/mbe/health` is PUBLIC (no API key required)
|
||||
- `/api/v2/service/start` and `/api/v2/service/stop` require API key
|
||||
- Frontend should send API key via query param or header
|
||||
|
||||
3. **Error Handling**: API returns clear error messages if:
|
||||
4. **Error Handling**: API returns clear error messages if:
|
||||
- Service already running (start)
|
||||
- Service not running (stop)
|
||||
- VLM not responding (health)
|
||||
@@ -122,4 +144,5 @@ These limitations are acceptable for current use case but can be enhanced in fut
|
||||
|
||||
| Version | Date | Changes |
|
||||
|---------|------|---------|
|
||||
| 1.0 | 2026-10-24 | Initial implementation complete |
|
||||
| 1.0 | 2026-10-24 | Initial implementation |
|
||||
| 1.1 | 2026-10-24 | Fixed route conflict, moved service_management to protected routes |
|
||||
Reference in New Issue
Block a user