Compare commits

..

No commits in common. "f5fc8b588f6f030dc3e1973021456d15ce4a2bcf" and "c32741bbc9f0a8d4a8b602341e06a010b9cb3c24" have entirely different histories.

3 changed files with 14 additions and 66 deletions

View File

@ -1,3 +1,2 @@
[alias]
runs = "run -- paper 1.19.4-545 --config data/config --backup data/backups --world data/worlds --jar data/paper.jar"
runrs = "run --release -- paper 1.19.4-545 --config data/config --backup data/backups --world data/worlds --jar data/paper.jar"
runs = "run -- paper --config data/config --backup data/backups --world data/worlds --jar data/paper.jar"

View File

@ -113,57 +113,16 @@ impl ServerCommand {
let backup_dir = self.backup_dir.canonicalize()?;
self.accept_eula()?;
let mut cmd = Command::new(&self.java);
// Apply JVM optimisation flags
// https://aikar.co/2018/07/02/tuning-the-jvm-g1gc-garbage-collector-flags-for-minecraft/
cmd.arg(format!("-Xms{}M", self.xms))
.arg(format!("-Xmx{}M", self.xmx))
.args([
"-XX:+UseG1GC",
"-XX:+ParallelRefProcEnabled",
"-XX:MaxGCPauseMillis=200",
"-XX:+UnlockExperimentalVMOptions",
"-XX:+DisableExplicitGC",
"-XX:+AlwaysPreTouch",
"-XX:G1HeapWastePercent=5",
"-XX:G1MixedGCCountTarget=4",
"-XX:G1MixedGCLiveThresholdPercent=90",
"-XX:G1RSetUpdatingPauseTimePercent=5",
"-XX:SurvivorRatio=32",
"-XX:+PerfDisableSharedMem",
"-XX:MaxTenuringThreshold=1",
"-Dusing.aikars.flags=https://mcflags.emc.gs",
"-Daikars.new.flags=true",
]);
if self.xms > 12 * 1024 {
cmd.args([
"-XX:G1NewSizePercent=40",
"-XX:G1MaxNewSizePercent=50",
"-XX:G1HeapRegionSize=16M",
"-XX:G1ReservePercent=15",
"-XX:InitiatingHeapOccupancyPercent=20",
]);
} else {
cmd.args([
"-XX:G1NewSizePercent=30",
"-XX:G1MaxNewSizePercent=40",
"-XX:G1HeapRegionSize=8M",
"-XX:G1ReservePercent=15",
"-XX:InitiatingHeapOccupancyPercent=15",
]);
}
cmd.current_dir(&config_dir)
let child = Command::new(&self.java)
.current_dir(&config_dir)
.arg("-jar")
.arg(&jar)
.arg("--universe")
.arg(&world_dir)
.arg("--nogui")
.stdin(Stdio::piped());
let child = cmd.spawn()?;
.stdin(Stdio::piped())
.spawn()?;
Ok(ServerProcess::new(
self.type_,

View File

@ -2,7 +2,7 @@ use crate::server::ServerType;
use flate2::write::GzEncoder;
use flate2::Compression;
use std::io::Write;
use std::path::{Path, PathBuf};
use std::path::PathBuf;
use std::process::Child;
#[link(name = "c")]
@ -108,21 +108,11 @@ impl ServerProcess {
tar.append_dir_all("worlds", &self.world_dir)?;
// Add all files from the config directory that aren't the cache
for entry in self
.config_dir
.read_dir()?
.filter_map(|e| e.ok())
.filter(|e| e.file_name() != "cache")
{
let tar_path = Path::new("config").join(entry.file_name());
if entry.file_type()?.is_dir() {
tar.append_dir_all(tar_path, entry.path())?;
} else {
tar.append_path_with_name(entry.path(), tar_path)?;
}
}
// We don't store all files in the config, as this would include caches
tar.append_path_with_name(
self.config_dir.join("server.properties"),
"config/server.properties",
)?;
// We add a file to the backup describing for what version it was made
let info = format!("{} {}", self.type_, self.version);
@ -138,6 +128,8 @@ impl ServerProcess {
tar.append_data(&mut header, "info.txt", info_bytes)?;
// tar.append_dir_all("config", &self.config_dir)?;
// Backup file gets finalized in the drop
Ok(())
@ -147,9 +139,7 @@ impl ServerProcess {
fn remove_old_backups(&mut self) -> std::io::Result<()> {
// The naming format used allows us to sort the backups by name and still get a sorting by
// creation time
let mut backups = self
.backup_dir
.read_dir()?
let mut backups = std::fs::read_dir(&self.backup_dir)?
.filter_map(|res| res.map(|e| e.path()).ok())
.collect::<Vec<PathBuf>>();
backups.sort();