0.12.0
Former-commit-id: 84eeb6984b8b0976ee36f094642be223e2a3a3cf
This commit is contained in:
parent
12e1d8fb2c
commit
4fa63f30d3
41
src/main.rs
41
src/main.rs
@ -1,6 +1,9 @@
|
|||||||
#![feature(proc_macro_hygiene, decl_macro)]
|
#![feature(proc_macro_hygiene, decl_macro)]
|
||||||
|
|
||||||
#[macro_use] extern crate rocket;
|
#[macro_use] extern crate rocket;
|
||||||
|
|
||||||
|
use serde::{Serialize, Deserialize};
|
||||||
|
|
||||||
use rocket::State;
|
use rocket::State;
|
||||||
use rocket::response::status::NotFound;
|
use rocket::response::status::NotFound;
|
||||||
use rocket::Data;
|
use rocket::Data;
|
||||||
@ -19,7 +22,7 @@ mod workunit;
|
|||||||
use workunit::WUnit;
|
use workunit::WUnit;
|
||||||
use workunit::EStatus;
|
use workunit::EStatus;
|
||||||
|
|
||||||
const VERSION: &str = "0.11.0";
|
const VERSION: &str = "0.12.0";
|
||||||
|
|
||||||
#[derive(Default, Debug)]
|
#[derive(Default, Debug)]
|
||||||
struct SharedState {
|
struct SharedState {
|
||||||
@ -38,6 +41,42 @@ fn version() -> &'static str {
|
|||||||
VERSION
|
VERSION
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[get("/stats")]
|
||||||
|
fn get_stats(shared: State<SharedState>) -> Json<Value> {
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
|
||||||
|
struct Stats {
|
||||||
|
queued: u32,
|
||||||
|
progress: u32,
|
||||||
|
completed: u32,
|
||||||
|
cancelled: u32,
|
||||||
|
error: u32,
|
||||||
|
length: u32
|
||||||
|
};
|
||||||
|
|
||||||
|
let list = shared.jobs.lock().unwrap().clone();
|
||||||
|
let mut stats: Stats = Stats {
|
||||||
|
queued: 0,
|
||||||
|
progress: 0,
|
||||||
|
completed: 0,
|
||||||
|
cancelled: 0,
|
||||||
|
error: 0,
|
||||||
|
length: 999
|
||||||
|
};
|
||||||
|
|
||||||
|
for job in list.values() {
|
||||||
|
match &job.status {
|
||||||
|
EStatus::Queued => stats.queued += 1,
|
||||||
|
EStatus::Reserved(a) => stats.progress += 1,
|
||||||
|
EStatus::Completed(a) => stats.completed += 1,
|
||||||
|
EStatus::Cancelled => stats.cancelled += 1,
|
||||||
|
EStatus::Error(a) => stats.error += 1
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
Json(serde_json::to_value(&stats).unwrap())
|
||||||
|
}
|
||||||
|
|
||||||
#[get("/get_jobs")]
|
#[get("/get_jobs")]
|
||||||
fn get_jobs(shared: State<SharedState>) -> Json<Value> {
|
fn get_jobs(shared: State<SharedState>) -> Json<Value> {
|
||||||
let list = shared.jobs.lock().unwrap().clone();
|
let list = shared.jobs.lock().unwrap().clone();
|
||||||
|
@ -4,7 +4,7 @@ set -euo pipefail
|
|||||||
IFS=$'\n\t'
|
IFS=$'\n\t'
|
||||||
|
|
||||||
base_url="$1"
|
base_url="$1"
|
||||||
version="0.11.0"
|
version="0.12.0"
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
sleep 30
|
sleep 30
|
||||||
@ -73,7 +73,7 @@ while true; do
|
|||||||
|
|
||||||
etype=`echo $job | jq -r '.description.options | keys | .[]'`
|
etype=`echo $job | jq -r '.description.options | keys | .[]'`
|
||||||
|
|
||||||
if [$etype != "FFMPEG"] && [$etype != "AOMENC" ]; then
|
if [ $etype != "FFMPEG" ] && [ $etype != "AOMENC" ]; then
|
||||||
echo "That's not a valid encoder!! Are you being attacked?"
|
echo "That's not a valid encoder!! Are you being attacked?"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user