mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: use record-conn handler for pretest-conn
This commit is contained in:
1 parent
9b9243a87c
commit
c6d3ce1e79
10 files changed
+166
-141
No files matched your search
+20
-4
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable consistent-return */
|
||||
/* eslint-disable no-undef */
|
||||
/// <reference types="./jssh" />
|
||||
|
||||
@@ -93,7 +94,13 @@ const steps = [
|
||||
operations: [
|
||||
() => {
|
||||
const res = exec1('bash -c "source /root/.nvm/nvm.sh && nvm install 14"', { NVM_NODEJS_ORG_MIRROR });
|
||||
const ver = res.output.split('Now using node v')[1].split(' ')[0];
|
||||
let ver;
|
||||
try {
|
||||
ver = res.output.split('Now using node v')[1].split(' ')[0];
|
||||
} catch (e) {
|
||||
log.error('Cannot parse version. Installation fail.');
|
||||
return 'retry';
|
||||
}
|
||||
setenv('PATH', `/root/.nvm/versions/node/v${ver}/bin:${__env.PATH}`);
|
||||
const rc_path = `/root/.${__env['SHELL'].endsWith('zsh') ? 'zsh' : 'bash'}rc`;
|
||||
if (!fs.exist(rc_path)) fs.writefile(rc_path, source_nvm);
|
||||
@@ -152,12 +159,17 @@ const steps = [
|
||||
Arch ? 'pacman --needed --quiet --noconfirm -S gcc fpc' : 'apt-get install -y g++ fp-compiler >/dev/null',
|
||||
],
|
||||
},
|
||||
{
|
||||
init: '正在安装沙箱 / Installing sandbox',
|
||||
operations: [
|
||||
`curl -fSL ${SANDBOX_DOWNLOAD} -o /usr/bin/sandbox`,
|
||||
'chmod +x /usr/bin/sandbox',
|
||||
],
|
||||
},
|
||||
{
|
||||
init: '正在安装 HydroOJ / Installing HydroOJ',
|
||||
operations: [
|
||||
'yarn global add hydrooj @hydrooj/ui-default @hydrooj/hydrojudge',
|
||||
() => http.download(SANDBOX_DOWNLOAD, '/usr/bin/sandbox'),
|
||||
'chmod +x /usr/bin/sandbox',
|
||||
() => fs.writefile('/root/.hydro/addon.json', '["@hydrooj/ui-default","@hydrooj/hydrojudge"]'),
|
||||
],
|
||||
},
|
||||
@@ -199,7 +211,11 @@ for (let i = 0; i < steps.length; i++) {
|
||||
if (!(step.skip && step.skip())) {
|
||||
for (const op of step.operations) {
|
||||
if (typeof op === 'string') {
|
||||
exec(op);
|
||||
let res = exec(op);
|
||||
while (res === 'retry') {
|
||||
log.warn('Retry...');
|
||||
res = exec(op);
|
||||
}
|
||||
if (__code !== 0) log.fatal('Error when running %s', op);
|
||||
} else op();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user