Skip to content

Commit

Permalink
rebase with conf sandbox PR
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaoticTempest committed Jan 5, 2023
1 parent e362f84 commit 9f8c59e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
17 changes: 17 additions & 0 deletions workspaces/src/network/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,20 @@ fn max_sandbox_json_payload_size() -> Result<u64> {
Ok(max_files)
}

/// Get the max files for workspaces. `NEAR_SANDBOX_MAX_FILES` env var will be used and if not
/// specified, will default to a max of 5000 handles by default as to not ulimit errors on certain
/// platforms like Windows WSL2.
fn max_files() -> Result<u64> {
let max_files = match std::env::var("NEAR_SANDBOX_MAX_FILES") {
Ok(val) => (&val)
.parse::<u64>()
.map_err(|err| ErrorKind::DataConversion.custom(err))?,
Err(_err) => 4096,
};

Ok(max_files)
}

/// Set extra configs for the sandbox defined by workspaces.
pub(crate) fn set_sandbox_configs(home_dir: &Path) -> Result<()> {
overwrite(
Expand All @@ -63,6 +77,9 @@ pub(crate) fn set_sandbox_configs(home_dir: &Path) -> Result<()> {
"json_payload_max_size": max_sandbox_json_payload_size()?,
},
},
"store": {
"max_open_files": max_files()?,
}
}),
)
}
8 changes: 1 addition & 7 deletions workspaces/src/network/server.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
use std::collections::hash_map::Entry;
use std::collections::HashMap;
use std::fs::File;
use std::io::BufReader;
use std::path::PathBuf;

use crate::error::{ErrorKind, SandboxErrorCode};
use crate::error::SandboxErrorCode;
use crate::network::Sandbox;
use crate::result::Result;

Expand Down

0 comments on commit 9f8c59e

Please sign in to comment.