Skip to content

Commit

Permalink
Merge pull request #65 from mvlabat/webhook-autoscaling
Browse files Browse the repository at this point in the history
Fix game server autoscaling
  • Loading branch information
vladbat00 authored Nov 20, 2021
2 parents 155fa1d + f2d7ca5 commit 4e6490d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions bins/matchmaker/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,9 @@ async fn serve_webhook_service(tx: Sender<MatchmakerMessage>, servers: Servers)
let servers = servers.all().await;
let active_players = tx.receiver_count() as u32
+ servers.iter().map(|s| s.player_count).sum::<u16>() as u32;
let total_capacity = servers.iter().map(|s| s.player_capacity).sum::<u16>() as u32;
let desired_replicas_count =
active_players.unstable_div_ceil(PLAYER_CAPACITY as u32);

let desired_replicas_count = active_players.unstable_div_ceil(total_capacity);
fleet_autoscale_review.response = Some(FleetAutoscaleResponse {
uid: fleet_autoscale_review.request.uid.clone(),
scale: desired_replicas_count != fleet_autoscale_review.request.status.replicas,
Expand Down
2 changes: 1 addition & 1 deletion libs/server_lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ pub fn init_level(
if let Some(agones) = agones {
let mut sdk = agones.sdk.clone();
TOKIO.spawn(async move {
if let Err(err) = sdk.mark_ready().await {
if let Err(err) = sdk.allocate().await {
log::error!(
"Failed to mark the Game Server as ready, exiting: {:?}",
err
Expand Down

0 comments on commit 4e6490d

Please sign in to comment.