Compare commits

...

7 Commits

Author SHA1 Message Date
Thomas Hobson a7fa1b47fe
Merge pull request #632 from ssahai/bugfix/catch_error
Handle process kills gracefully
2023-11-01 14:06:28 +13:00
Thomas Hobson 48102b612f
Merge pull request #623 from devnote-dev/update-crystal
Replace old Crystal version
2023-11-01 14:04:34 +13:00
Thomas Hobson f785f655d5
Merge pull request #630 from Aetheridon/master
Added files for Python 3.11.0
2023-11-01 14:04:06 +13:00
Shubham Sahai d8af1ee301 Try-Catch process kills to handle dead processes 2023-10-30 20:09:01 +08:00
Shubham Sahai dc4bb294b6 bugfix: catch error - "e is not defined" 2023-10-26 02:42:28 +08:00
Aetheridon 18743a3369 Added files for Python 3.11.0 2023-10-19 14:47:45 +01:00
devnote-dev f70ecdd8b4 feat(packages): replace old crystal version 2023-09-03 20:29:22 +01:00
12 changed files with 91 additions and 27 deletions

View File

@ -146,7 +146,7 @@ class Job {
'--nofile=' + this.runtime.max_open_files, '--nofile=' + this.runtime.max_open_files,
'--fsize=' + this.runtime.max_file_size, '--fsize=' + this.runtime.max_file_size,
]; ];
const timeout_call = [ const timeout_call = [
'timeout', 'timeout',
'-s', '-s',
@ -158,7 +158,7 @@ class Job {
prlimit.push('--as=' + memory_limit); prlimit.push('--as=' + memory_limit);
} }
const proc_call = [ const proc_call = [
'nice', 'nice',
...timeout_call, ...timeout_call,
...prlimit, ...prlimit,
@ -204,7 +204,16 @@ class Job {
(timeout >= 0 && (timeout >= 0 &&
set_timeout(async _ => { set_timeout(async _ => {
this.logger.info(`Timeout exceeded timeout=${timeout}`); this.logger.info(`Timeout exceeded timeout=${timeout}`);
process.kill(proc.pid, 'SIGKILL'); try {
process.kill(proc.pid, 'SIGKILL');
}
catch (e) {
// Could already be dead and just needs to be waited on
this.logger.debug(
`Got error while SIGKILLing process ${proc}:`,
e
);
}
}, timeout)) || }, timeout)) ||
null; null;
this.#active_timeouts.push(kill_timeout); this.#active_timeouts.push(kill_timeout);
@ -214,7 +223,16 @@ class Job {
event_bus.emit('stderr', data); event_bus.emit('stderr', data);
} else if (stderr.length > this.runtime.output_max_size) { } else if (stderr.length > this.runtime.output_max_size) {
this.logger.info(`stderr length exceeded`); this.logger.info(`stderr length exceeded`);
process.kill(proc.pid, 'SIGKILL'); try {
process.kill(proc.pid, 'SIGKILL');
}
catch (e) {
// Could already be dead and just needs to be waited on
this.logger.debug(
`Got error while SIGKILLing process ${proc}:`,
e
);
}
} else { } else {
stderr += data; stderr += data;
output += data; output += data;
@ -226,7 +244,16 @@ class Job {
event_bus.emit('stdout', data); event_bus.emit('stdout', data);
} else if (stdout.length > this.runtime.output_max_size) { } else if (stdout.length > this.runtime.output_max_size) {
this.logger.info(`stdout length exceeded`); this.logger.info(`stdout length exceeded`);
process.kill(proc.pid, 'SIGKILL'); try {
process.kill(proc.pid, 'SIGKILL');
}
catch (e) {
// Could already be dead and just needs to be waited on
this.logger.debug(
`Got error while SIGKILLing process ${proc}:`,
e
);
}
} else { } else {
stdout += data; stdout += data;
output += data; output += data;
@ -254,7 +281,7 @@ class Job {
if (this.state !== job_states.PRIMED) { if (this.state !== job_states.PRIMED) {
throw new Error( throw new Error(
'Job must be in primed state, current state: ' + 'Job must be in primed state, current state: ' +
this.state.toString() this.state.toString()
); );
} }
@ -271,22 +298,22 @@ class Job {
const { emit_event_bus_result, emit_event_bus_stage } = const { emit_event_bus_result, emit_event_bus_stage } =
event_bus === null event_bus === null
? { ? {
emit_event_bus_result: () => {}, emit_event_bus_result: () => { },
emit_event_bus_stage: () => {}, emit_event_bus_stage: () => { },
} }
: { : {
emit_event_bus_result: (stage, result, event_bus) => { emit_event_bus_result: (stage, result, event_bus) => {
const { error, code, signal } = result; const { error, code, signal } = result;
event_bus.emit('exit', stage, { event_bus.emit('exit', stage, {
error, error,
code, code,
signal, signal,
}); });
}, },
emit_event_bus_stage: (stage, event_bus) => { emit_event_bus_stage: (stage, event_bus) => {
event_bus.emit('stage', stage); event_bus.emit('stage', stage);
}, },
}; };
if (this.runtime.compiled) { if (this.runtime.compiled) {
this.logger.debug('Compiling'); this.logger.debug('Compiling');
@ -352,9 +379,9 @@ class Job {
const [_, ruid, euid, suid, fuid] = uid_line.split(/\s+/); const [_, ruid, euid, suid, fuid] = uid_line.split(/\s+/);
const [_1, state, user_friendly] = state_line.split(/\s+/); const [_1, state, user_friendly] = state_line.split(/\s+/);
const proc_id_int = parse_int(proc_id); const proc_id_int = parse_int(proc_id);
// Skip over any processes that aren't ours. // Skip over any processes that aren't ours.
if (ruid != this.uid && euid != this.uid) return -1; if (ruid != this.uid && euid != this.uid) return -1;
@ -362,7 +389,7 @@ class Job {
// Zombie process, just needs to be waited, regardless of the user id // Zombie process, just needs to be waited, regardless of the user id
if (!to_wait.includes(proc_id_int)) if (!to_wait.includes(proc_id_int))
to_wait.push(proc_id_int); to_wait.push(proc_id_int);
return -1; return -1;
} }
// We should kill in all other state (Sleep, Stopped & Running) // We should kill in all other state (Sleep, Stopped & Running)
@ -397,7 +424,7 @@ class Job {
// Then clear them out of the process tree // Then clear them out of the process tree
try { try {
process.kill(proc, 'SIGKILL'); process.kill(proc, 'SIGKILL');
} catch { } catch (e) {
// Could already be dead and just needs to be waited on // Could already be dead and just needs to be waited on
this.logger.debug( this.logger.debug(
`Got error while SIGKILLing process ${proc}:`, `Got error while SIGKILLing process ${proc}:`,

View File

@ -2,6 +2,6 @@
PREFIX=$(realpath $(dirname $0)) PREFIX=$(realpath $(dirname $0))
curl -L "https://github.com/crystal-lang/crystal/releases/download/0.36.1/crystal-0.36.1-1-linux-x86_64.tar.gz" -o crystal.tar.gz curl -L "https://github.com/crystal-lang/crystal/releases/download/1.9.2/crystal-1.9.2-1-linux-x86_64.tar.gz" -o crystal.tar.gz
tar xzf crystal.tar.gz --strip-components=1 tar xzf crystal.tar.gz --strip-components=1
rm crystal.tar.gz rm crystal.tar.gz

View File

@ -1,5 +1,5 @@
{ {
"language": "crystal", "language": "crystal",
"version": "0.36.1", "version": "1.9.2",
"aliases": ["crystal", "cr"] "aliases": ["crystal", "cr"]
} }

21
packages/python/3.11.0/build.sh vendored Normal file
View File

@ -0,0 +1,21 @@
#!/bin/bash
PREFIX=$(realpath $(dirname $0))
mkdir -p build
cd build
curl "https://www.python.org/ftp/python/3.11.0/Python-3.11.0.tgz" -o python.tar.gz
tar xzf python.tar.gz --strip-components=1
rm python.tar.gz
./configure --prefix "$PREFIX" --with-ensurepip=install
make -j$(nproc)
make install -j$(nproc)
cd ..
rm -rf build
bin/pip3 install numpy scipy pandas pycryptodome whoosh bcrypt passlib sympy xxhash base58 cryptography PyNaCl

1
packages/python/3.11.0/environment vendored Normal file
View File

@ -0,0 +1 @@
export PATH=$PWD/bin:$PATH

5
packages/python/3.11.0/metadata.json vendored Normal file
View File

@ -0,0 +1,5 @@
{
"language": "python",
"version": "3.11.0",
"aliases": ["py", "py3", "python3", "python3.11"]
}

3
packages/python/3.11.0/run vendored Normal file
View File

@ -0,0 +1,3 @@
#!/bin/bash
python3.11 "$@"

7
packages/python/3.11.0/test.py vendored Normal file
View File

@ -0,0 +1,7 @@
working = True
match working:
case True:
print("OK")
case False:
print()