Compare commits

...

5 Commits

12 changed files with 69 additions and 48 deletions

72
Cargo.lock generated
View File

@ -65,7 +65,7 @@ checksum = "31e6e93155431f3931513b243d371981bb2770112b370c82745a1d19d2f99364"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 1.0.105",
]
[[package]]
@ -315,7 +315,7 @@ dependencies = [
"proc-macro2",
"quote",
"scratch",
"syn",
"syn 1.0.105",
]
[[package]]
@ -332,7 +332,7 @@ checksum = "1362b0ddcfc4eb0a1f57b68bd77dd99f0e826958a96abd0ae9bd092e114ffed6"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 1.0.105",
]
[[package]]
@ -526,7 +526,7 @@ checksum = "bdfb8ce053d86b91919aad980c220b1fb8401a9394410e1c289ed7e66b61835d"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 1.0.105",
]
[[package]]
@ -589,6 +589,26 @@ dependencies = [
"wasi 0.11.0+wasi-snapshot-preview1",
]
[[package]]
name = "git-version"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ad568aa3db0fcbc81f2f116137f263d7304f512a1209b35b85150d3ef88ad19"
dependencies = [
"git-version-macro",
]
[[package]]
name = "git-version-macro"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53010ccb100b96a67bc32c0175f0ed1426b31b655d562898e57325f81c023ac0"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.48",
]
[[package]]
name = "h2"
version = "0.3.15"
@ -1010,7 +1030,7 @@ checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 1.0.105",
]
[[package]]
@ -1112,7 +1132,7 @@ dependencies = [
"pest_meta",
"proc-macro2",
"quote",
"syn",
"syn 1.0.105",
]
[[package]]
@ -1143,7 +1163,7 @@ checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 1.0.105",
]
[[package]]
@ -1179,7 +1199,7 @@ dependencies = [
"proc-macro-error-attr",
"proc-macro2",
"quote",
"syn",
"syn 1.0.105",
"version_check",
]
@ -1196,9 +1216,9 @@ dependencies = [
[[package]]
name = "proc-macro2"
version = "1.0.47"
version = "1.0.78"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725"
checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae"
dependencies = [
"unicode-ident",
]
@ -1344,6 +1364,7 @@ dependencies = [
"dashmap",
"futures",
"futures-util",
"git-version",
"handlebars",
"http",
"hyper",
@ -1498,9 +1519,9 @@ dependencies = [
[[package]]
name = "quote"
version = "1.0.21"
version = "1.0.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179"
checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
dependencies = [
"proc-macro2",
]
@ -1702,7 +1723,7 @@ dependencies = [
"proc-macro2",
"quote",
"rust-embed-utils",
"syn",
"syn 1.0.105",
"walkdir",
]
@ -1866,7 +1887,7 @@ checksum = "255abe9a125a985c05190d687b320c12f9b1f0b99445e608c21ba0782c719ad8"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 1.0.105",
]
[[package]]
@ -2009,7 +2030,7 @@ dependencies = [
"proc-macro-error",
"proc-macro2",
"quote",
"syn",
"syn 1.0.105",
]
[[package]]
@ -2029,6 +2050,17 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "syn"
version = "2.0.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "tempfile"
version = "3.3.0"
@ -2078,7 +2110,7 @@ checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 1.0.105",
]
[[package]]
@ -2160,7 +2192,7 @@ checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 1.0.105",
]
[[package]]
@ -2244,7 +2276,7 @@ checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 1.0.105",
]
[[package]]
@ -2504,7 +2536,7 @@ dependencies = [
"once_cell",
"proc-macro2",
"quote",
"syn",
"syn 1.0.105",
"wasm-bindgen-shared",
]
@ -2538,7 +2570,7 @@ checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 1.0.105",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]

View File

@ -1,8 +1,8 @@
# https://whitfin.io/speeding-up-rust-docker-builds/
# TODO: https://stackoverflow.com/questions/57389547/how-to-define-the-context-for-a-docker-build-as-a-specific-commit-on-one-of-the
# docker pull rust:1.66-slim-buster
FROM rust@sha256:98c9b1fca0c9a6183369daf9efadb57c634340ae877bb027aeadf72afdd086a3 as build
# docker pull rust:1.75-slim-buster
FROM rust@sha256:981dda194caa72aa466cb8789aa6d18ee1af22bc77f1c0b8dc9690f5d3e8fe82 as build
WORKDIR /
ENV USER root
@ -78,7 +78,4 @@ WORKDIR /home/ptth_user
COPY --from=build /ptth/target/release/ptth_relay ./
COPY --from=build /ptth/handlebars/relay ./handlebars/relay
ARG git_version
RUN echo -n "$git_version" > ./git_version.txt
CMD ["/usr/bin/tini", "--", "./ptth_relay"]

View File

@ -8,12 +8,11 @@ DOCKER_TAG="ptth:latest"
mkdir -p app_packages
git archive --format=tar "$GIT_COMMIT" | sudo docker build -t "$DOCKER_TAG" --build-arg "git_version=$GIT_COMMIT" -
git archive --format=tar "$GIT_COMMIT" | sudo docker build -t "$DOCKER_TAG" -
sudo docker run --rm "$DOCKER_TAG" tar -c \
ptth_relay \
handlebars \
git_version.txt \
| gzip > "app_packages/ptth_relay_$GIT_COMMIT_SHORT.tar.gz"
sudo docker build -f app_package_Dockerfile -t ptth_app_host:latest .

View File

@ -38,6 +38,7 @@ tracing-futures = "0.2.4"
tracing-subscriber = "0.2.15"
ptth_core = { path = "../ptth_core", version = "2.0.0" }
git-version = "0.3.9"
[dependencies.reqwest]
version = "0.11.13"

View File

@ -1,3 +1,3 @@
pub async fn read () -> Option <String> {
tokio::fs::read_to_string ("git_version.txt").await.ok ()
pub fn read () -> &'static str {
git_version::git_version!(args = ["--abbrev=16", "--always", "--dirty=-modified"])
}

View File

@ -264,7 +264,7 @@ struct ServerEntry <'a> {
#[derive (Serialize)]
struct ServerListPage <'a> {
dev_mode: bool,
git_version: Option <String>,
git_version: &'static str,
servers: Vec <ServerEntry <'a>>,
news_url: Option <String>,
connected_server_count: usize,
@ -308,7 +308,7 @@ async fn handle_server_list_internal (state: &Relay)
dev_mode = guard.iso.dev_mode.is_some ();
news_url = guard.news_url.clone ();
}
let git_version = git_version::read ().await;
let git_version = git_version::read ();
let server_list = scraper_api::v1_server_list (&state).await;
@ -780,12 +780,7 @@ pub async fn run_relay (
{
let handlebars = Arc::new (load_templates (asset_root)?);
if let Some (x) = git_version::read ().await {
info! ("ptth_relay Git version: {:?}", x);
}
else {
info! ("ptth_relay not built from Git");
}
info! ("ptth_relay Git version: {}", git_version::read ());
if let Some (config_reload_path) = config_reload_path {
let state_2 = state.clone ();

View File

@ -2,11 +2,11 @@
use std::{
convert::TryFrom,
error::Error,
path::PathBuf,
sync::Arc,
};
use anyhow::Context;
use clap::{App, SubCommand};
use tracing_subscriber::{
fmt,
@ -21,7 +21,7 @@ use ptth_relay::{
};
#[tokio::main]
async fn main () -> Result <(), Box <dyn Error>> {
async fn main () -> anyhow::Result<()> {
fmt ()
.with_env_filter (EnvFilter::from_default_env ())
.with_span_events (FmtSpan::CLOSE)
@ -48,7 +48,7 @@ async fn main () -> Result <(), Box <dyn Error>> {
}
let config_path = PathBuf::from ("config/ptth_relay.toml");
let config = Config::from_file (&config_path).await?;
let config = Config::from_file (&config_path).await.context("couldn't load ptth_relay.toml")?;
let (shutdown_rx, forced_shutdown) = ptth_core::graceful_shutdown::init_with_force ();

View File

@ -39,7 +39,7 @@
<p class="fine">
Rendered by PTTH relay server.
Copyright 2020-2021 "Trish" ReactorScram. Licensed under the
Copyright 2020-2024 "Trish" ReactorScram. Licensed under the
<a href="https://www.gnu.org/licenses/agpl-3.0.html">GNU AGPLv3.</a>
<a href="https://six-five-six-four.com/git/reactor/ptth">Download source code</a>
</p>

View File

@ -90,15 +90,11 @@ AIABAACAAQAAgAEAAIABAACAAQAAgAEAAIABAACAAQAA" rel="icon" type="image/x-icon" />
<a href="../audit_log">Audit log</a>
<div style="color: #888; padding-top: 1em;">
{{#if git_version}}
Git version: {{git_version}}
{{else}}
Not built from Git
{{/if}}
<p>
Rendered by PTTH relay server.
Copyright 2020-2021 "Trish" ReactorScram. Licensed under the
Copyright 2020-2024 "Trish" ReactorScram. Licensed under the
<a href="https://www.gnu.org/licenses/agpl-3.0.html">GNU AGPLv3.</a>
<a href="https://six-five-six-four.com/git/reactor/ptth">Download source code</a>
</p>

View File

@ -131,7 +131,7 @@ AIABAACAAQAAgAEAAIABAACAAQAAgAEAAIABAACAAQAA" rel="icon" type="image/x-icon" />
<p class="fine">
Rendered by PTTH end server.
Copyright 2020-2021 "Trish" ReactorScram. Licensed under the
Copyright 2020-2024 "Trish" ReactorScram. Licensed under the
<a href="https://www.gnu.org/licenses/agpl-3.0.html">GNU AGPLv3.</a>
<a href="https://six-five-six-four.com/git/reactor/ptth">Download source code</a>
</p>

View File

@ -42,7 +42,7 @@
<p class="fine">
Rendered by PTTH end server.
Copyright 2020-2021 "Trish" ReactorScram. Licensed under the
Copyright 2020-2024 "Trish" ReactorScram. Licensed under the
<a href="https://www.gnu.org/licenses/agpl-3.0.html">GNU AGPLv3.</a>
<a href="https://six-five-six-four.com/git/reactor/ptth">Download source code</a>
</p>

View File

@ -4,3 +4,4 @@ set -euo pipefail
cargo check --target x86_64-pc-windows-gnu -p ptth -p ptth_quic
cargo check --target x86_64-unknown-linux-gnu -p ptth -p ptth_quic
cargo test -p ptth -p ptth_quic