mirror of
https://github.com/Noratrieb/cargo-bisect-rustc-service.git
synced 2026-01-14 16:25:01 +01:00
Compare commits
8 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 95480163c9 | |||
| 557edb1abd | |||
| 316a40442e | |||
| 13f89b68ef | |||
| 8bd8676314 | |||
| 89f533e357 | |||
| e4d1c77422 | |||
|
|
ae0ea732e9 |
8 changed files with 746 additions and 275 deletions
1
.envrc
Normal file
1
.envrc
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
use nix
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -1,2 +1,2 @@
|
||||||
/target
|
/target
|
||||||
bisect.sqlite
|
bisect.sqlite
|
||||||
|
|
|
||||||
963
Cargo.lock
generated
963
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -9,6 +9,9 @@ edition = "2021"
|
||||||
axum = "0.5.16"
|
axum = "0.5.16"
|
||||||
chrono = { version = "0.4.22", features = ["serde", "clock"] }
|
chrono = { version = "0.4.22", features = ["serde", "clock"] }
|
||||||
color-eyre = "0.6.2"
|
color-eyre = "0.6.2"
|
||||||
|
metrics = "0.22.3"
|
||||||
|
metrics-exporter-prometheus = { version = "0.14.0", default-features = false, features = ["http-listener"] }
|
||||||
|
once_cell = "1.19.0"
|
||||||
rusqlite = { version = "0.28.0", features = ["bundled", "uuid", "chrono"] }
|
rusqlite = { version = "0.28.0", features = ["bundled", "uuid", "chrono"] }
|
||||||
serde = { version = "1.0.145", features = ["derive"] }
|
serde = { version = "1.0.145", features = ["derive"] }
|
||||||
tempdir = "0.3.7"
|
tempdir = "0.3.7"
|
||||||
|
|
|
||||||
16
Dockerfile
16
Dockerfile
|
|
@ -1,4 +1,4 @@
|
||||||
FROM rust as build
|
FROM rust:1.77 as build
|
||||||
|
|
||||||
RUN rustup toolchain install nightly
|
RUN rustup toolchain install nightly
|
||||||
RUN rustup default nightly
|
RUN rustup default nightly
|
||||||
|
|
@ -12,22 +12,30 @@ COPY Cargo.toml Cargo.lock ./
|
||||||
RUN mkdir src
|
RUN mkdir src
|
||||||
RUN echo "fn main() {}" > src/main.rs
|
RUN echo "fn main() {}" > src/main.rs
|
||||||
|
|
||||||
RUN cargo build --release -Zsparse-registry
|
RUN cargo build --release
|
||||||
|
|
||||||
COPY src ./src
|
COPY src ./src
|
||||||
COPY index.html index.html
|
COPY index.html index.html
|
||||||
|
|
||||||
# now rebuild with the proper main
|
# now rebuild with the proper main
|
||||||
RUN touch src/main.rs
|
RUN touch src/main.rs
|
||||||
RUN cargo build --release -Zsparse-registry
|
RUN cargo build --release
|
||||||
|
|
||||||
### RUN
|
### RUN
|
||||||
FROM rust
|
FROM rust:1.77
|
||||||
|
|
||||||
RUN cargo install cargo-bisect-rustc
|
RUN cargo install cargo-bisect-rustc
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
# random user
|
||||||
|
RUN useradd --create-home bisector
|
||||||
|
USER bisector
|
||||||
|
|
||||||
|
# this server listens on port 4000 and 4001 (metrics)
|
||||||
|
EXPOSE 4000
|
||||||
|
EXPOSE 4001
|
||||||
|
|
||||||
COPY --from=build /app/target/release/cargo-bisect-rustc-service cargo-bisect-rustc-service
|
COPY --from=build /app/target/release/cargo-bisect-rustc-service cargo-bisect-rustc-service
|
||||||
|
|
||||||
CMD ["/app/cargo-bisect-rustc-service"]
|
CMD ["/app/cargo-bisect-rustc-service"]
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,9 @@
|
||||||
# cargo-bisect-rustc-service
|
# cargo-bisect-rustc-service
|
||||||
|
|
||||||
|
**⚠️ this service has been turned off due to lack of usage ⚠️**
|
||||||
|
|
||||||
|
if you think it's useful you should tell me so i can turn it on again
|
||||||
|
|
||||||
a small web service that bisects rustc for you
|
a small web service that bisects rustc for you
|
||||||
|
|
||||||
https://nilstrieb.dev/bisect-rustc
|
https://bisect-rustc.noratrieb.dev
|
||||||
|
|
|
||||||
3
shell.nix
Normal file
3
shell.nix
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
{ pkgs ? import <nixpkgs> { } }: pkgs.mkShell {
|
||||||
|
packages = with pkgs; [ rustup ];
|
||||||
|
}
|
||||||
26
src/main.rs
26
src/main.rs
|
|
@ -4,7 +4,10 @@ mod bisect;
|
||||||
mod db;
|
mod db;
|
||||||
mod toolchain;
|
mod toolchain;
|
||||||
|
|
||||||
use std::sync::{mpsc, Arc, Mutex};
|
use std::{
|
||||||
|
future,
|
||||||
|
sync::{mpsc, Arc, Mutex},
|
||||||
|
};
|
||||||
|
|
||||||
use crate::bisect::Job;
|
use crate::bisect::Job;
|
||||||
use axum::{
|
use axum::{
|
||||||
|
|
@ -15,6 +18,7 @@ use axum::{
|
||||||
Extension, Json,
|
Extension, Json,
|
||||||
};
|
};
|
||||||
use color_eyre::eyre::Context;
|
use color_eyre::eyre::Context;
|
||||||
|
use metrics_exporter_prometheus::{PrometheusBuilder, PrometheusHandle};
|
||||||
use rusqlite::Connection;
|
use rusqlite::Connection;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
@ -38,6 +42,22 @@ async fn main() -> color_eyre::Result<()> {
|
||||||
)
|
)
|
||||||
.init();
|
.init();
|
||||||
|
|
||||||
|
let metrics_app = async {
|
||||||
|
let prom_handle = setup_metrics();
|
||||||
|
let router: Router =
|
||||||
|
Router::new().route("/metrics", get(move || future::ready(prom_handle.render())));
|
||||||
|
info!("Starting up metrics server on port 4001");
|
||||||
|
axum::Server::bind(&"0.0.0.0:4001".parse().unwrap())
|
||||||
|
.serve(router.into_make_service())
|
||||||
|
.await
|
||||||
|
.wrap_err("failed to start server")
|
||||||
|
};
|
||||||
|
|
||||||
|
tokio::try_join!(metrics_app, main_server())?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn main_server() -> color_eyre::Result<()> {
|
||||||
let (job_queue_send, job_queue_recv) = mpsc::sync_channel(10);
|
let (job_queue_send, job_queue_recv) = mpsc::sync_channel(10);
|
||||||
|
|
||||||
let sqlite_db = env::var("SQLITE_DB").unwrap_or_else(|_| "bisect.sqlite".to_string());
|
let sqlite_db = env::var("SQLITE_DB").unwrap_or_else(|_| "bisect.sqlite".to_string());
|
||||||
|
|
@ -115,6 +135,7 @@ async fn do_bisection(
|
||||||
body: String,
|
body: String,
|
||||||
send_channel: Extension<SendChannel>,
|
send_channel: Extension<SendChannel>,
|
||||||
) -> impl IntoResponse {
|
) -> impl IntoResponse {
|
||||||
|
metrics::counter!("bisections").increment(1);
|
||||||
let job_id = Uuid::new_v4();
|
let job_id = Uuid::new_v4();
|
||||||
|
|
||||||
let job = Job::new(job_id, body, options.0);
|
let job = Job::new(job_id, body, options.0);
|
||||||
|
|
@ -130,3 +151,6 @@ async fn do_bisection(
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pub fn setup_metrics() -> PrometheusHandle {
|
||||||
|
PrometheusBuilder::new().install_recorder().unwrap()
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue