Compare commits
2 Commits
c32741bbc9
...
f5fc8b588f
| Author | SHA1 | Date |
|---|---|---|
|
|
f5fc8b588f | |
|
|
640364405f |
|
|
@ -1,2 +1,3 @@
|
|||
[alias]
|
||||
runs = "run -- paper --config data/config --backup data/backups --world data/worlds --jar data/paper.jar"
|
||||
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"
|
||||
|
|
|
|||
|
|
@ -113,16 +113,57 @@ impl ServerCommand {
|
|||
let backup_dir = self.backup_dir.canonicalize()?;
|
||||
|
||||
self.accept_eula()?;
|
||||
let mut cmd = Command::new(&self.java);
|
||||
|
||||
let child = Command::new(&self.java)
|
||||
.current_dir(&config_dir)
|
||||
// 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)
|
||||
.arg("-jar")
|
||||
.arg(&jar)
|
||||
.arg("--universe")
|
||||
.arg(&world_dir)
|
||||
.arg("--nogui")
|
||||
.stdin(Stdio::piped())
|
||||
.spawn()?;
|
||||
.stdin(Stdio::piped());
|
||||
|
||||
let child = cmd.spawn()?;
|
||||
|
||||
Ok(ServerProcess::new(
|
||||
self.type_,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use crate::server::ServerType;
|
|||
use flate2::write::GzEncoder;
|
||||
use flate2::Compression;
|
||||
use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Child;
|
||||
|
||||
#[link(name = "c")]
|
||||
|
|
@ -108,11 +108,21 @@ impl ServerProcess {
|
|||
|
||||
tar.append_dir_all("worlds", &self.world_dir)?;
|
||||
|
||||
// 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",
|
||||
)?;
|
||||
// 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 add a file to the backup describing for what version it was made
|
||||
let info = format!("{} {}", self.type_, self.version);
|
||||
|
|
@ -128,8 +138,6 @@ 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(())
|
||||
|
|
@ -139,7 +147,9 @@ 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 = std::fs::read_dir(&self.backup_dir)?
|
||||
let mut backups = self
|
||||
.backup_dir
|
||||
.read_dir()?
|
||||
.filter_map(|res| res.map(|e| e.path()).ok())
|
||||
.collect::<Vec<PathBuf>>();
|
||||
backups.sort();
|
||||
|
|
|
|||
Loading…
Reference in New Issue