From 1011015b29c00480b1a7bcb5e2d98abdb363fc75 Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Thu, 21 Jul 2022 21:42:47 +0200 Subject: show match url in planetwars_client --- planetwars-client/src/main.rs | 4 ++++ planetwars-server/configuration.toml | 3 +++ planetwars-server/src/lib.rs | 3 +++ planetwars-server/src/modules/bot_api.rs | 5 +++++ proto/bot_api.proto | 1 + 5 files changed, 16 insertions(+) diff --git a/planetwars-client/src/main.rs b/planetwars-client/src/main.rs index 25a6725..30397a5 100644 --- a/planetwars-client/src/main.rs +++ b/planetwars-client/src/main.rs @@ -29,6 +29,10 @@ async fn main() { let created_match = create_match(channel.clone()).await.unwrap(); run_player(bot_config, created_match.player_key, channel).await; + println!( + "Match completed. Watch the replay at {}", + created_match.match_url + ); tokio::time::sleep(Duration::from_secs(1)).await; } diff --git a/planetwars-server/configuration.toml b/planetwars-server/configuration.toml index 13012f9..87347d9 100644 --- a/planetwars-server/configuration.toml +++ b/planetwars-server/configuration.toml @@ -1,5 +1,8 @@ database_url = "postgresql://planetwars:planetwars@localhost/planetwars" +# front-end is served here in development, which proxies to the backend +root_url = "http://localhost:3000" + python_runner_image = "python:3.10-slim-buster" container_registry_url = "localhost:9001" diff --git a/planetwars-server/src/lib.rs b/planetwars-server/src/lib.rs index c8585f8..050048c 100644 --- a/planetwars-server/src/lib.rs +++ b/planetwars-server/src/lib.rs @@ -45,6 +45,9 @@ pub struct GlobalConfig { /// this will be used when running bots pub container_registry_url: String, + /// webserver root url, used to construct links + pub root_url: String, + /// directory where bot code will be stored pub bots_directory: String, /// directory where match logs will be stored diff --git a/planetwars-server/src/modules/bot_api.rs b/planetwars-server/src/modules/bot_api.rs index cb12275..3bc002c 100644 --- a/planetwars-server/src/modules/bot_api.rs +++ b/planetwars-server/src/modules/bot_api.rs @@ -135,6 +135,11 @@ impl pb::bot_api_service_server::BotApiService for BotApiServer { Ok(Response::new(pb::CreatedMatch { match_id: created_match.base.id, player_key, + // TODO: can we avoid hardcoding this? + match_url: format!( + "{}/matches/{}", + self.runner_config.root_url, created_match.base.id + ), })) } } diff --git a/proto/bot_api.proto b/proto/bot_api.proto index 4b07c7c..69a319a 100644 --- a/proto/bot_api.proto +++ b/proto/bot_api.proto @@ -30,6 +30,7 @@ message MatchRequest { message CreatedMatch { int32 match_id = 1; string player_key = 2; + string match_url = 3; } service BotApiService { -- cgit v1.2.3