Skip to content

Conversation

cdaringe
Copy link
Contributor

Description

Contributions

  • I changed x because y
  • I added the new feature x.

Checklist

  • I added one or multiple labels which best describes this PR.
  • I have tested the changes locally.
  • This PR has a reviewer on it.
  • I have validated my changes in a docker container and on Ubuntu. (Only needed for Odin or Docker Changes)

@@ -14,7 +14,7 @@ RUN cargo chef prepare --recipe-path recipe.json
# ------------------ #
FROM lukemathwalker/cargo-chef:latest-rust-${RUST_VERSION} as cacher
WORKDIR /data/odin
RUN apt-get update && apt-get install -y cmake
RUN apt-get update && apt-get install -y cmake libpcap-dev
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pcap used to sniff for packets

@@ -21,7 +21,7 @@ member_clippy:
cargo clippy

docker-build: setup
docker compose -f ./docker-compose.dev.yml build
docker compose -f ./docker-compose.dev.yml build --progress=plain
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because docker stdio hides critical build failure output by default

@@ -2,6 +2,7 @@ version: "3"
services:
odin:
image: mbround18/odin:latest
platform: "linux/amd64"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm on mac m1 with arm.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should only really be in your docker-compose.dev.yaml but have you had success running valheim on m1? weve had lots of issues before with people struggling with it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arrggg no i couldn't dev at all! i should have searched earlier 😢

@@ -58,6 +58,9 @@ pub struct Configuration {

/// Sets the save interval in seconds
pub save_interval: Option<u16>,

/// Steam home dirname
pub steam_home_dirname: String,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the repo is very much coded to only be executing in cointainer. i just couldnt get the container to ever boot. the steam script segfaulting and not emitting any output :(

i figured "maybe i can at least unit/integration test my feature" without actually running a real server. however, 'odin configure' and 'odin install' were some pre-reqs that i only started to hack through to test this approach, but well exceeded my timebox today

Path::new("/home/steam/.bashrc"),
PathBuf::from_iter([&self.steam_home_dirname, "valheim"]),
PathBuf::from_iter([&self.steam_home_dirname, "scripts"]),
PathBuf::from_iter([&self.steam_home_dirname, ".bashrc"])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my attempts to support running external of the container, by de-hardcoding these values

error!(target: "commands_start", "Error: {}", err);
exit(1);
})
.expect("failed to daemonize server")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i didn't see a repo error enum, but didn't want to a) introduce one or b) go .unwrap() crazy, so i opted to just use String as the Err variant to get sane messaging propagated up. not married to it (or any of this really) at all!

match pause_on_idle_s > 0 {
true => loop {
let mut child = run_server(&config);
let _ = server::spawn_kill_on_idle(&mut child, pause_on_idle_s).map_err(|err| {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let _ = server::spawn_kill_on_idle(&mut child, pause_on_idle_s).map_err(|err| {
let _ = server::kill_on_idle(&mut child, pause_on_idle_s).map_err(|err| {


use pcap::{Capture, Device};

pub fn spawn_kill_on_idle(child: &mut Child, pause_on_idle_s: u32) -> Result<(), String> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, the plan was to pause the process. i realized... i'd need another cgroup to pause anything, and i'm not yet talented enough to do that. so, my first pass was going to be naively killing the pid, then rebooting it on traffic. then on a second pass, try the whole pause/resume bit, once i can learn about firing up that server in a pausable cgroup.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arrrg i'm such a dummy! the proc does respond to SIGSTOP/SIGCONT already. no cgroups required


use pcap::{Capture, Device};

pub fn spawn_kill_on_idle(child: &mut Child, pause_on_idle_s: u32) -> Result<(), String> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub fn spawn_kill_on_idle(child: &mut Child, pause_on_idle_s: u32) -> Result<(), String> {
pub fn kill_on_idle(child: &mut Child, pause_on_idle_s: u32) -> Result<(), String> {

}
child.kill().map_err(|e| e.to_string())?;
Ok(())
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really, this is probably wrong to block the main thread. should probably have this as a bg thread, with an Arc<Mutex<Child>> that is swapped on restart

@mbround18
Copy link
Owner

@cdaringe this is a really good first pass! :) ill start diving through it later tonight, apologies on delay man ive been busy remodeling a kitchen

@cdaringe
Copy link
Contributor Author

closing for now, just to halt the constant auto-merges 😄

@cdaringe cdaringe closed this Jul 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants