Skip to content

Commit

Permalink
build
Browse files Browse the repository at this point in the history
  • Loading branch information
enola-dkfz committed Mar 4, 2024
1 parent 826a3a9 commit fea75df
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 14 deletions.
5 changes: 5 additions & 0 deletions Cross.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[target.aarch64-unknown-linux-gnu]
pre-build = ["dpkg --add-architecture arm64 && apt-get update && apt-get install --assume-yes libssl-dev:arm64 && rm -rf /var/lib/apt/lists/*"]

[target.x86_64-unknown-linux-gnu]
pre-build = ["dpkg --add-architecture amd64 && apt-get update && apt-get install --assume-yes libssl-dev:amd64 && rm -rf /var/lib/apt/lists/*"]
29 changes: 29 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use std::env;

use build_data::get_git_dirty;

/// Outputs a readable version number such as
/// 0.4.0 (if git commit is clean)
/// 0.4.0-SNAPSHOT (if git commit is dirty, should not happen in CI/CD builds)
fn version() -> String {
let version = String::from(env!("CARGO_PKG_VERSION"));
match get_git_dirty().unwrap() {
false => {
version
},
true => {
format!("{}-SNAPSHOT", version)
}
}
}

fn main() {
build_data::set_GIT_COMMIT_SHORT();
build_data::set_GIT_DIRTY();
build_data::set_BUILD_DATE();
build_data::set_BUILD_TIME();
// We must always run this build script as otherwise, we would cache old versions of CQL maps
//build_data::no_debug_rebuilds();
println!("cargo:rustc-env=SAMPLY_USER_AGENT=Samply.Prism.{}/{}", env!("CARGO_PKG_NAME"), version());

}
8 changes: 1 addition & 7 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub(crate) static CONFIG: Lazy<Config> = Lazy::new(|| {
})
});

const CLAP_FOOTER: &str = "For proxy support, environment variables HTTP_PROXY, HTTPS_PROXY, ALL_PROXY and NO_PROXY (and their lower-case variants) are supported. Usually, you want to set HTTP_PROXY *and* HTTPS_PROXY or set ALL_PROXY if both values are the same.\n\nFor updates and detailed usage instructions, visit https://github.com/samply/focus";
const CLAP_FOOTER: &str = "For proxy support, environment variables HTTP_PROXY, HTTPS_PROXY, ALL_PROXY and NO_PROXY (and their lower-case variants) are supported. Usually, you want to set HTTP_PROXY *and* HTTPS_PROXY or set ALL_PROXY if both values are the same.\n\nFor updates and detailed usage instructions, visit https://github.com/samply/prism";

#[derive(Parser, Debug)]
#[clap(
Expand Down Expand Up @@ -62,10 +62,6 @@ struct CliArgs {
#[clap(long, env, default_value = "0.0.0.0:8080")]
pub bind_addr: SocketAddr,

/// Authorization header
#[clap(long, env, value_parser)]
auth_header: Option<String>,

/// Target_application_name
#[clap(long, env, value_parser, default_value = "focus")]
target: String,
Expand All @@ -81,7 +77,6 @@ pub(crate) struct Config {
pub cors_origin: AllowOrigin,
pub project: String,
pub bind_addr: SocketAddr,
pub auth_header: Option<String>,
pub query: String,
pub target: String,
}
Expand All @@ -99,7 +94,6 @@ impl Config {
cors_origin: cli_args.cors_origin,
project: cli_args.project,
bind_addr: cli_args.bind_addr,
auth_header: cli_args.auth_header,
query: get_query(),
target: cli_args.target,
};
Expand Down
6 changes: 0 additions & 6 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,12 @@ use thiserror::Error;
pub enum PrismError {
#[error("Configuration error: {0}")]
ConfigurationError(String),
#[error("Cannot open file: {0}")]
FileOpeningError(String),
#[error("Parsing error: {0}")]
ParsingError(String),
#[error("Beam error: {0}")]
BeamError(String),
#[error("CQL tampered with: {0}")]
DeserializationError(serde_json::Error),
#[error("Serialization error: {0}")]
SerializationError(String),
#[error("Invalid Header Value: {0}")]
InvalidHeaderValue(http::header::InvalidHeaderValue),
#[error("Decode error: {0}")]
DecodeError(base64::DecodeError),
#[error("Unexpected WorkStatus: {0:?}")]
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ async fn wait_for_beam_proxy() -> beam_lib::Result<()> {
const MAX_RETRIES: u8 = 3;
let mut tries = 1;
loop {
match reqwest::get(format!("http://localhost:8082/v1/health")).await {
match reqwest::get(format!("{}v1/health", CONFIG.beam_proxy_url.to_string())).await {
//FIXME why doesn't it work with url from config
Ok(res) if res.status() == StatusCode::OK => return Ok(()),
_ if tries <= MAX_RETRIES => tries += 1,
Expand Down

0 comments on commit fea75df

Please sign in to comment.