diff --git a/services/app/apps/codebattle/lib/codebattle/tournament/strategy/base.ex b/services/app/apps/codebattle/lib/codebattle/tournament/strategy/base.ex index b3056dcb2..b6c4a79e0 100644 --- a/services/app/apps/codebattle/lib/codebattle/tournament/strategy/base.ex +++ b/services/app/apps/codebattle/lib/codebattle/tournament/strategy/base.ex @@ -238,7 +238,8 @@ defmodule Codebattle.Tournament.Base do |> Enum.map(&Tournament.Player.new!/1) # TODO: add timeout without blocking server for rematches - :timer.sleep(5000) + timeout_ms = Application.get_env(:codebattle, :tournament_rematch_timeout_ms) + :timer.sleep(timeout_ms) game_id = create_game(tournament, match_id, players) match = %Tournament.Match{ diff --git a/services/app/config/config.exs b/services/app/config/config.exs index 73f3b344e..bbd02909c 100644 --- a/services/app/config/config.exs +++ b/services/app/config/config.exs @@ -102,6 +102,7 @@ config :codebattle, fake_html_to_image: false config :codebattle, use_only_token_auth: false config :codebattle, show_extension_popup: true config :codebattle, app_version: System.get_env("APP_VERSION", "dev") +config :codebattle, tournament_rematch_timeout_ms: 5000 config :codebattle, deployed_at: System.get_env("DEPLOYED_AT") || Calendar.strftime(DateTime.utc_now(), "%c") diff --git a/services/app/config/releases.exs b/services/app/config/releases.exs index 57a83e230..29c91330a 100644 --- a/services/app/config/releases.exs +++ b/services/app/config/releases.exs @@ -57,12 +57,16 @@ use_external_js = System.get_env("CODEBATTLE_USE_EXTERNAL_JS") == "true" use_only_token_auth = System.get_env("CODEBATTLE_USE_ONLY_TOKEN_AUTH") == "true" show_extension_popup = System.get_env("CODEBATTLE_SHOW_EXTENSION_POPUP") == "true" +tournament_rematch_timeout_ms = + "CODEBATTLE_TOURNAMENT_REMATCH_TIMEOUT_MS" |> System.get_env("5000") |> String.to_integer() + config :codebattle, admins: admins config :codebattle, import_github_tasks: import_github_tasks config :codebattle, create_bot_games: create_bot_games config :codebattle, use_external_js: use_external_js config :codebattle, use_only_token_auth: use_only_token_auth config :codebattle, show_extension_popup: show_extension_popup +config :codebattle, tournament_rematch_timeout_ms: tournament_rematch_timeout_ms config :codebattle, Codebattle.Plugs, rollbar_api_key: System.get_env("ROLLBAR_API_KEY") diff --git a/services/app/config/test.exs b/services/app/config/test.exs index c046de44e..83108302c 100644 --- a/services/app/config/test.exs +++ b/services/app/config/test.exs @@ -68,6 +68,7 @@ config :codebattle, ws_port: 4001 config :codebattle, admins: ["admin"] config :codebattle, freeze_time: true +config :codebattle, tournament_rematch_timeout_ms: 5 config :codebattle, user_rank_server: false config :codebattle, create_bot_games: false