rustploy 0.1.35

Rustploy PaaS daemon — lightweight self-hosted deployment platform
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! `Command::JobRunNow`: dispara uma execução avulsa de um job
//! (`jobs::runner::spawn`).

use crate::bootstrap::state::AppState;
use shared::Response as RpResponse;

pub async fn handle(state: AppState, id: String) -> RpResponse {
    let job = match crate::store::job::get(&state.db, &id).await {
        Ok(Some(j)) => j,
        Ok(None) => return RpResponse::err("NotFound", "job not found"),
        Err(e) => return RpResponse::err("DatabaseError", e.to_string()),
    };

    match crate::features::jobs::runner::spawn(&state.jobs_ctx(), job).await {
        Ok(run) => RpResponse::JobRun(run),
        Err(e) => RpResponse::err("JobRunError", e.to_string()),
    }
}