Skip to content

Commit

Permalink
Merge pull request #293 from stakwork/set-gbm
Browse files Browse the repository at this point in the history
Set gbm
  • Loading branch information
Evanfeenstra authored Sep 9, 2024
2 parents 84ab225 + 8d58c3e commit 6fe7cec
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ pub enum SwarmCmd {
GetDockerImageTags(GetDockerImageTagsDetails),
UpdateUser(UpdateUserDetails),
GetApiToken,
SetGlobalMemLimit(u64),
}

#[derive(Serialize, Deserialize, Debug, Clone)]
Expand Down
13 changes: 13 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,3 +297,16 @@ impl Stack {
}
}
}

#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)]
struct GbmRes {
global_mem_limit: u64,
}
pub fn set_global_mem_limit(gbm: u64) -> Result<String> {
log::info!("Set Global Memory Limit ===> {:?}", gbm);
use std::sync::atomic::Ordering;
GLOBAL_MEM_LIMIT.store(gbm, Ordering::Relaxed);
Ok(serde_json::to_string(&GbmRes {
global_mem_limit: gbm,
})?)
}
5 changes: 5 additions & 0 deletions src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,11 @@ pub async fn handle(
let response = get_api_token(&boltwall).await?;
return Ok(serde_json::to_string(&response)?);
}
SwarmCmd::SetGlobalMemLimit(gbm) => {
state.stack.global_mem_limit = Some(gbm);
must_save_stack = true;
Some(crate::config::set_global_mem_limit(gbm)?)
}
},
Cmd::Relay(c) => {
let client = state.clients.relay.get(tag).context("no relay client")?;
Expand Down

0 comments on commit 6fe7cec

Please sign in to comment.