Server half of sccache-dash
Polls sccache's counters every 10 s, keeps a JSON-lines history, and serves the page and its API on 127.0.0.1: one difference-with-reset mechanism behind every range, per-language time saved, problems, a copyable summary, and extra tables for multi-level and distributed caches. The page is embedded from crates/ui/dist when it exists, with a placeholder until then. POST /api/zero refuses foreign Host and Origin headers. Tests run against a stand-in sccache script; sample fixtures for the multi-level and distributed shapes are made up.
This commit is contained in:
1 parent
a8e7bd66cf
commit
3cbc02e631
18 files changed
+3654
No files matched your search
@@ -0,0 +1,37 @@
|
||||
//! Puts the page into the binary. The page is what `trunk build --release` writes to
|
||||
//! `crates/ui/dist`; until it has been built, a placeholder page stands in for it.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
const PLACEHOLDER: &str = "<!doctype html>
|
||||
<meta charset=\"utf-8\">
|
||||
<title>sccache-dash</title>
|
||||
<body style=\"font: 16px sans-serif; margin: 3em auto; max-width: 34em;\">
|
||||
<h1>The sccache dashboard page is not built</h1>
|
||||
<p>The server is running and its <a href=\"/api/view?range=24h\">API</a> answers, but the page
|
||||
that draws it is missing. Run <code>just build</code> in the repository (it runs
|
||||
<code>trunk build --release</code> in <code>crates/ui</code>) and start sccache-dash again.
|
||||
";
|
||||
|
||||
fn main() {
|
||||
let crates = Path::new(&std::env::var("CARGO_MANIFEST_DIR").unwrap())
|
||||
.parent()
|
||||
.expect("crates/server has a parent")
|
||||
.to_path_buf();
|
||||
let dist = crates.join("ui").join("dist");
|
||||
// Checked on every build, so the page is picked up as soon as `trunk build` has made it.
|
||||
println!(
|
||||
"cargo:rerun-if-changed={}",
|
||||
dist.join("index.html").display()
|
||||
);
|
||||
|
||||
let site = if dist.join("index.html").is_file() {
|
||||
dist
|
||||
} else {
|
||||
let out = Path::new(&std::env::var("OUT_DIR").unwrap()).join("site");
|
||||
std::fs::create_dir_all(&out).unwrap();
|
||||
std::fs::write(out.join("index.html"), PLACEHOLDER).unwrap();
|
||||
out
|
||||
};
|
||||
println!("cargo:rustc-env=DASH_SITE={}", site.display());
|
||||
}
|
||||
Reference in new issue
Block a user