Skip to content
This repository was archived by the owner on Nov 8, 2020. It is now read-only.

Commit fa9599f

Browse files
committed
更新langs.yaml
1 parent 232c205 commit fa9599f

File tree

7 files changed

+337
-181
lines changed

7 files changed

+337
-181
lines changed

examples/langs.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ py3:
5656
php:
5757
type: interpreter
5858
code_file: foo.php
59-
execute: /usr/bin/php foo.php
59+
execute: /usr/bin/php ${name}
6060
rs:
6161
type: compiler
6262
compile: /usr/bin/rustc -O -o ${dir}/${name} ${dir}/foo.rs
@@ -70,7 +70,7 @@ hs:
7070
js:
7171
type: interpreter
7272
code_file: foo.js
73-
execute: /usr/bin/jsc ${dir}/foo.js
73+
execute: /usr/bin/jsc ${dir}/${name}
7474
go:
7575
type: compiler
7676
compile: /usr/bin/go build -o ${name} foo.go
@@ -79,7 +79,7 @@ go:
7979
rb:
8080
type: interpreter
8181
code_file: foo.rb
82-
execute: /usr/bin/ruby foo.rb
82+
execute: /usr/bin/ruby ${name}
8383
cs:
8484
type: compiler
8585
compile: /usr/bin/mcs -optimize+ -out:${dir}/${name} ${dir}/foo.cs

judger/log.js

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,28 @@ function warp(func) {
55
};
66
}
77

8-
module.exports = {
9-
log: warp(console.log),
10-
error: warp(console.error),
11-
info: warp(console.info),
12-
warn: warp(console.warn),
13-
debug: warp(console.debug),
14-
submission(id, payload = {}) {
15-
console.log(`${new Date()} ${id}`, payload);
16-
},
17-
};
8+
class Logger {
9+
constructor() {
10+
this.log = warp(console.log, 'log');
11+
this.error = warp(console.error, 'error');
12+
this.info = warp(console.info, 'info');
13+
this.warn = warp(console.warn, 'warn');
14+
this.debug = warp(console.debug, 'debug');
15+
this.submission = (id, payload = {}) => {
16+
console.log(`${new Date()} ${id}`, payload);
17+
};
18+
}
19+
20+
logger(logger) {
21+
this.log = warp(logger.log, 'log');
22+
this.error = warp(logger.error, 'error');
23+
this.info = warp(logger.info, 'info');
24+
this.warn = warp(logger.warn, 'warn');
25+
this.debug = warp(logger.debug, 'debug');
26+
this.submission = (id, payload = {}) => {
27+
logger.log(`${new Date()} ${id}`, payload);
28+
};
29+
}
30+
}
31+
32+
module.exports = new Logger();

module/hydro.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"id": "judger",
33
"version": "1.2.0",
4-
"description": "HydroJudger",
5-
"master": true
4+
"description": "HydroJudger"
65
}

module/service.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@
22
/* eslint-disable no-await-in-loop */
33
const fs = require('fs');
44
const path = require('path');
5+
const cluster = require('cluster');
56
const child = require('child_process');
7+
const yaml = require('js-yaml');
68

79
async function postInit() {
10+
// Only start a single daemon
11+
if (cluster.isMaster || cluster.worker.id > 1) return;
812
const config = require('../judger/config');
9-
// eslint-disable-next-line import/no-unresolved
10-
config.LANGS = require('./__langs.json');
11-
const { mkdirp, rmdir, compilerText } = require('../judger/utils');
1213
const log = require('../judger/log');
14+
log.logger(global.Hydro.lib.logger);
15+
config.LANGS = yaml.safeLoad(await global.Hydro.model.system.get('judger.langs'));
16+
const { mkdirp, rmdir, compilerText } = require('../judger/utils');
1317
const tmpfs = require('../judger/tmpfs');
1418
const { FormatError, CompileError, SystemError } = require('../judger/error');
1519
const { STATUS_COMPILE_ERROR, STATUS_SYSTEM_ERROR } = require('../judger/status');

module/setting.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
langs: {
3+
type: 'text',
4+
default: JSON.stringify(require('./__langs.json')),
5+
description: 'Language file settings',
6+
},
7+
};

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
"minimist": "^1.2.5",
1111
"p-queue": "^6.4.0",
1212
"shell-quote": "^1.7.2",
13-
"systeminformation": "^4.26.5",
13+
"systeminformation": "^4.26.9",
1414
"ws": "^7.3.0"
1515
},
1616
"license": "GPL-3.0-only",
1717
"devDependencies": {
18-
"eslint": "^6.2.2",
19-
"eslint-config-airbnb-base": "^14.1.0",
20-
"eslint-plugin-import": "^2.20.2",
21-
"hydro-build": "^1.0.1"
18+
"eslint": "^7.2.0",
19+
"eslint-config-airbnb-base": "^14.2.0",
20+
"eslint-plugin-import": "^2.21.2",
21+
"hydro-build": "^1.0.4"
2222
},
2323
"bin": {
2424
"judger": "judger/entrypoint.js"

0 commit comments

Comments
 (0)