mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01: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",
|
"name": "@hydrooj/hydrojudge",
|
||||||
"version": "2.0.13",
|
"version": "2.0.14",
|
||||||
"main": "package.json",
|
"main": "package.json",
|
||||||
"author": "masnn",
|
"author": "masnn",
|
||||||
"os": [
|
|
||||||
"linux"
|
|
||||||
],
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.20.0",
|
"axios": "^0.20.0",
|
||||||
"bson": "^4.1.0",
|
"bson": "^4.1.0",
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ const cache: any = {};
|
|||||||
|
|
||||||
async function stackSize() {
|
async function stackSize() {
|
||||||
let output = '';
|
let output = '';
|
||||||
|
try {
|
||||||
const context: any = {
|
const context: any = {
|
||||||
lang: 'ccWithoutO2',
|
lang: 'ccWithoutO2',
|
||||||
code: `#include <iostream>
|
code: `#include <iostream>
|
||||||
@@ -51,6 +52,9 @@ int main(){
|
|||||||
for (const clean of context.clean) await clean().catch();
|
for (const clean of context.clean) await clean().catch();
|
||||||
tmpfs.umount(context.tmpdir);
|
tmpfs.umount(context.tmpdir);
|
||||||
fs.removeSync(context.tmpdir);
|
fs.removeSync(context.tmpdir);
|
||||||
|
} catch (e) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
const a = output.split(' ');
|
const a = output.split(' ');
|
||||||
return parseInt(a[a.length - 2], 10);
|
return parseInt(a[a.length - 2], 10);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,17 @@
|
|||||||
import child from 'child_process';
|
import child from 'child_process';
|
||||||
import fs from 'fs-extra';
|
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') {
|
export function mount(path: string, size = '32m') {
|
||||||
fs.ensureDirSync(path);
|
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) {
|
export function umount(path: string) {
|
||||||
child.execSync(`umount ${path}`);
|
if (linux) child.execSync(`umount ${path}`);
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user