Skip to content
Snippets Groups Projects
Unverified Commit ca3ab6a7 authored by Dominic Meiser's avatar Dominic Meiser
Browse files

fix memory limit

parent f4fe73bf
No related branches found
No related tags found
No related merge requests found
......@@ -19,16 +19,22 @@ use std::{
collections::BTreeSet,
fmt::Display,
fs,
io::{self, BufRead as _, Write}
io::{self, BufRead as _, Write},
sync::RwLock
};
static MEM_LIMIT: RwLock<String> = RwLock::new(String::new());
#[derive(Debug, Parser)]
struct Args {
#[clap(short = 'C', long, default_value = ".")]
directory: PathBuf,
#[clap(short = 'c', long, default_value = "23ws-malo")]
course: String
course: String,
#[clap(short, long, default_value = "2G")]
mem_limit: String
}
#[allow(non_camel_case_types, clippy::upper_case_acronyms)]
......@@ -146,6 +152,7 @@ fn ask_time(question: impl Display) -> Time {
fn main() {
let args = Args::parse();
*(MEM_LIMIT.write().unwrap()) = args.mem_limit;
// process arguments
let directory = args.directory.canonicalize_utf8().unwrap();
......
......@@ -8,7 +8,7 @@ use crate::{
iotro::{intro, outro},
render::ffmpeg::{Ffmpeg, FfmpegInput},
time::{format_date, Time},
Project, ProjectSourceMetadata, Resolution
Project, ProjectSourceMetadata, Resolution, MEM_LIMIT
};
use anyhow::{bail, Context};
use camino::{Utf8Path as Path, Utf8PathBuf as PathBuf};
......@@ -21,8 +21,6 @@ use std::{
process::{Command, Stdio}
};
const MEMORY_LIMIT: &str = "2G";
const INTRO_LEN: Time = Time {
seconds: 3,
micros: 0
......@@ -48,7 +46,7 @@ fn cmd() -> Command {
.arg("-q")
.arg("--expand-environment=no")
.arg("-p")
.arg(format!("MemoryMax={MEMORY_LIMIT}"))
.arg(format!("MemoryMax={}", MEM_LIMIT.read().unwrap()))
.arg("--user");
// we use busybox ash for having a shell that outputs commands with -x
cmd.arg("busybox")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment