feat: add workflow studio and postgres support
This commit is contained in:
@@ -93,10 +93,7 @@ pub fn routes() -> Router<AppState> {
|
||||
|
||||
async fn status(State(state): State<AppState>, headers: HeaderMap) -> AppResult<Json<Value>> {
|
||||
check_auth(&headers, &state)?;
|
||||
Ok(Json(
|
||||
serde_json::to_value(state.comfyui.status_response().await)
|
||||
.unwrap_or_else(|_| json!({ "status": "unknown" })),
|
||||
))
|
||||
Ok(Json(external_comfyui_status(&state).await))
|
||||
}
|
||||
|
||||
async fn start_comfyui(
|
||||
@@ -104,27 +101,19 @@ async fn start_comfyui(
|
||||
headers: HeaderMap,
|
||||
) -> AppResult<Json<Value>> {
|
||||
check_auth(&headers, &state)?;
|
||||
state
|
||||
.comfyui
|
||||
.start()
|
||||
.await
|
||||
.map_err(|err| AppError::Internal(anyhow::anyhow!(err)))?;
|
||||
Ok(Json(json!({
|
||||
"success": true,
|
||||
"comfyui": state.comfyui.status_response().await
|
||||
"message": "内置 Docker ComfyUI 工作台已移除;请配置外部 ComfyUI 或使用 /workflows 工作流画布。",
|
||||
"comfyui": external_comfyui_status_value(&state).await
|
||||
})))
|
||||
}
|
||||
|
||||
async fn stop_comfyui(State(state): State<AppState>, headers: HeaderMap) -> AppResult<Json<Value>> {
|
||||
check_auth(&headers, &state)?;
|
||||
state
|
||||
.comfyui
|
||||
.stop()
|
||||
.await
|
||||
.map_err(|err| AppError::Internal(anyhow::anyhow!(err)))?;
|
||||
Ok(Json(json!({
|
||||
"success": true,
|
||||
"comfyui": state.comfyui.status_response().await
|
||||
"message": "内置 Docker ComfyUI 工作台已移除;BoosAPI 不再管理 ComfyUI 进程生命周期。",
|
||||
"comfyui": external_comfyui_status_value(&state).await
|
||||
})))
|
||||
}
|
||||
|
||||
@@ -133,14 +122,10 @@ async fn restart_comfyui(
|
||||
headers: HeaderMap,
|
||||
) -> AppResult<Json<Value>> {
|
||||
check_auth(&headers, &state)?;
|
||||
state
|
||||
.comfyui
|
||||
.restart()
|
||||
.await
|
||||
.map_err(|err| AppError::Internal(anyhow::anyhow!(err)))?;
|
||||
Ok(Json(json!({
|
||||
"success": true,
|
||||
"comfyui": state.comfyui.status_response().await
|
||||
"message": "内置 Docker ComfyUI 工作台已移除;请在外部 ComfyUI 服务侧重启。",
|
||||
"comfyui": external_comfyui_status_value(&state).await
|
||||
})))
|
||||
}
|
||||
|
||||
@@ -187,6 +172,33 @@ fn local_api_base(state: &AppState) -> String {
|
||||
state.comfyui.model_backend_url()
|
||||
}
|
||||
|
||||
async fn external_comfyui_status(state: &AppState) -> Value {
|
||||
json!({
|
||||
"success": true,
|
||||
"comfyui": external_comfyui_status_value(state).await,
|
||||
})
|
||||
}
|
||||
|
||||
async fn external_comfyui_status_value(state: &AppState) -> Value {
|
||||
let status = state.comfyui.status_response().await;
|
||||
let reachable = state.comfyui.health_check().await;
|
||||
json!({
|
||||
"status": if reachable { "running" } else { "unavailable" },
|
||||
"pid": null,
|
||||
"uptime_secs": 0,
|
||||
"mode": "external",
|
||||
"model_backend": status.model_backend,
|
||||
"base_url": status.base_url,
|
||||
"version": status.version,
|
||||
"last_error": if reachable {
|
||||
Value::Null
|
||||
} else {
|
||||
json!("外部 ComfyUI 不可达;内置 Docker ComfyUI 工作台已移除,请配置 comfyui.base_url 或使用 /workflows 工作流画布。")
|
||||
},
|
||||
"dockerManaged": false,
|
||||
})
|
||||
}
|
||||
|
||||
fn check_auth(headers: &HeaderMap, state: &AppState) -> AppResult<()> {
|
||||
let expected = format!("Bearer {}", state.config.auth.auth_token);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user