diff options
author | Ilion Beyst <ilion.beyst@gmail.com> | 2022-01-23 13:23:23 +0100 |
---|---|---|
committer | Ilion Beyst <ilion.beyst@gmail.com> | 2022-01-23 13:23:23 +0100 |
commit | a79b338e90db1948f6587ab02e149e73bb1842f0 (patch) | |
tree | 42e0e3d5458f7cef76514960e4ff0de872c11646 /planetwars-server | |
parent | f62196d983c04a94b892086a4ea6926bd7b6e4fb (diff) | |
download | planetwars.dev-a79b338e90db1948f6587ab02e149e73bb1842f0.tar.xz planetwars.dev-a79b338e90db1948f6587ab02e149e73bb1842f0.zip |
run all bots in python docker for now
Diffstat (limited to 'planetwars-server')
-rw-r--r-- | planetwars-server/src/routes/matches.rs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/planetwars-server/src/routes/matches.rs b/planetwars-server/src/routes/matches.rs index fed0f7b..94a5f45 100644 --- a/planetwars-server/src/routes/matches.rs +++ b/planetwars-server/src/routes/matches.rs @@ -5,7 +5,7 @@ use axum::{ Json, }; use hyper::StatusCode; -use planetwars_matchrunner::{run_match, MatchConfig, MatchPlayer}; +use planetwars_matchrunner::{docker_runner::DockerBotSpec, run_match, MatchConfig, MatchPlayer}; use rand::{distributions::Alphanumeric, Rng}; use serde::{Deserialize, Serialize}; @@ -53,10 +53,13 @@ pub async fn play_match( players.push(MatchPlayer { name: bot.name.clone(), - path: PathBuf::from(BOTS_DIR).join(code_bundle.path), - argv: shlex::split(&bot_config.run_command) - // TODO: this is an user error, should ideally be handled before we get here - .ok_or_else(|| StatusCode::INTERNAL_SERVER_ERROR)?, + bot_spec: Box::new(DockerBotSpec { + code_path: PathBuf::from(BOTS_DIR).join(code_bundle.path), + image: "python:3.10-slim-buster".to_string(), + argv: shlex::split(&bot_config.run_command) + // TODO: this is an user error, should ideally be handled before we get here + .ok_or_else(|| StatusCode::INTERNAL_SERVER_ERROR)?, + }), }); bot_ids.push(matches::MatchPlayerData { bot_id: bot.id }); @@ -66,7 +69,7 @@ pub async fn play_match( map_name: "hex".to_string(), map_path, log_path: PathBuf::from(MATCHES_DIR).join(&log_file_name), - players: players, + players, }; tokio::spawn(run_match_task( |