Make server able to run old or new binary so that we can compare the actix version with this one

This commit is contained in:
James Wilson
2021-07-16 17:58:26 +01:00
parent 81a0140c3b
commit 582c49413b
5 changed files with 344 additions and 208 deletions
@@ -1,30 +1,45 @@
use super::commands;
use crate::server::{self, Server, Command};
/// Start a telemetry core server. We'll use `cargo run` by default, to ensure that
/// the code we run is uptodate, but you can also provide env vars to configure the binary
/// that runs for the shard and core process:
/// Start a telemetry server. We'll use `cargo run` by default, but you can also provide
/// env vars to configure the binary that runs for the shard and core process. Either:
///
/// TELEMETRY_SHARD_BIN - path to telemetry_shard binary
/// TELEMETRY_CORE_BIN - path to telemetry_core binary
async fn start_server(release_mode: bool) -> Server {
/// - `TELEMETRY_BIN` - path to the telemetry binary (which can function as shard _and_ core)
///
/// Or alternately neither/one/both of:
///
/// - `TELEMETRY_SHARD_BIN` - path to telemetry_shard binary
/// - `TELEMETRY_CORE_BIN` - path to telemetry_core binary
///
/// Whatever is not provided will be substituted with a `cargo run` variant instead.
pub async fn start_server(release_mode: bool) -> Server {
if let Ok(bin) = std::env::var("TELEMETRY_BIN") {
return Server::start(server::StartOpts::SingleProcess {
command: Command::new(bin)
}).await.unwrap();
}
let shard_command = std::env::var("TELEMETRY_SHARD_BIN")
.map(|val| Command::new(val))
.unwrap_or_else(|_| commands::cargo_run_telemetry_shard(release_mode).expect("valid shard command"));
.unwrap_or_else(|_| commands::cargo_run_telemetry_shard(release_mode).expect("must be in rust workspace to run shard command"));
let core_command = std::env::var("TELEMETRY_CORE_BIN")
.map(|val| Command::new(val))
.unwrap_or_else(|_| commands::cargo_run_telemetry_core(release_mode).expect("valid core command"));
.unwrap_or_else(|_| commands::cargo_run_telemetry_core(release_mode).expect("must be in rust workspace to run core command"));
Server::start(server::StartOpts { shard_command, core_command }).await.unwrap()
Server::start(server::StartOpts::ShardAndCore {
shard_command,
core_command
}).await.unwrap()
}
/// Start a telemetry server using debug builds for compile speed
/// Start a telemetry core server in debug mode. see [`start_server`] for details.
pub async fn start_server_debug() -> Server {
start_server(false).await
}
/// Start a telemetry server using release builds for performance accuracy
/// Start a telemetry core server in release mode. see [`start_server`] for details.
pub async fn start_server_release() -> Server {
start_server(true).await
}