mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
judge: ignore tmpfs error
This commit is contained in:
1 parent
b8c316c44b
commit
4b7f18baaa
3 files changed
+13
-6
No files matched your search
@@ -1,11 +1,8 @@
|
||||
{
|
||||
"name": "@hydrooj/hydrojudge",
|
||||
"version": "2.0.13",
|
||||
"version": "2.0.14",
|
||||
"main": "package.json",
|
||||
"author": "masnn",
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"dependencies": {
|
||||
"axios": "^0.20.0",
|
||||
"bson": "^4.1.0",
|
||||
|
||||
@@ -20,6 +20,7 @@ const cache: any = {};
|
||||
|
||||
async function stackSize() {
|
||||
let output = '';
|
||||
try {
|
||||
const context: any = {
|
||||
lang: 'ccWithoutO2',
|
||||
code: `#include <iostream>
|
||||
@@ -51,6 +52,9 @@ int main(){
|
||||
for (const clean of context.clean) await clean().catch();
|
||||
tmpfs.umount(context.tmpdir);
|
||||
fs.removeSync(context.tmpdir);
|
||||
} catch (e) {
|
||||
return -1;
|
||||
}
|
||||
const a = output.split(' ');
|
||||
return parseInt(a[a.length - 2], 10);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
import child from 'child_process';
|
||||
import fs from 'fs-extra';
|
||||
import os from 'os';
|
||||
import { Logger } from 'hydrooj/dist/logger';
|
||||
|
||||
const logger = new Logger('judge');
|
||||
const linux = os.platform() === 'linux';
|
||||
if (!linux) logger.warn('Not running on linux. tmpfs disabled.');
|
||||
|
||||
export function mount(path: string, size = '32m') {
|
||||
fs.ensureDirSync(path);
|
||||
child.execSync(`mount tmpfs ${path} -t tmpfs -o size=${size}`);
|
||||
if (linux) child.execSync(`mount tmpfs ${path} -t tmpfs -o size=${size}`);
|
||||
}
|
||||
|
||||
export function umount(path: string) {
|
||||
child.execSync(`umount ${path}`);
|
||||
if (linux) child.execSync(`umount ${path}`);
|
||||
}
|
||||
Reference in new issue
Block a user