create-yeow 0.2.123 → 0.2.125
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
Binary file
|
|
@@ -221,7 +221,7 @@ async function initServer() {
|
|
|
221
221
|
const eula = resolve(SERVER, 'eula.txt');
|
|
222
222
|
if (existsSync(eula) && readFileSync(eula, 'utf-8').includes('eula=true')) return;
|
|
223
223
|
|
|
224
|
-
if (
|
|
224
|
+
if (EULA) {
|
|
225
225
|
if (!existsSync(resolve(SERVER, 'server.properties'))) {
|
|
226
226
|
info('Initializing...');
|
|
227
227
|
await new Promise(r => { const p = spawn('java', ['-Xmx4G', '-Xms4G', '-jar', jar, '--nogui'], { cwd: SERVER, stdio: ['pipe', 'inherit', 'inherit'] }); setTimeout(() => { p.kill(); r(); }, 120000); p.on('exit', r); p.on('error', r); });
|
|
@@ -429,7 +429,7 @@ async function printFormattedError(err) {
|
|
|
429
429
|
}
|
|
430
430
|
|
|
431
431
|
function startServer() {
|
|
432
|
-
const jvmArgs = ['-Xmx4G', '-Xms4G', '-Dyeow.dev=true', '-Dyeow.ws.port=' + WS_PORT];
|
|
432
|
+
const jvmArgs = ['-Xmx4G', '-Xms4G', '-Dfile.encoding=UTF-8', '-Dstdout.encoding=UTF-8', '-Dyeow.dev=true', '-Dyeow.ws.port=' + WS_PORT];
|
|
433
433
|
info(`\nStarting Paper ${PAPER_VERSION} server...`);
|
|
434
434
|
proc = spawn('java', [...jvmArgs, '-jar', resolve(SERVER, PAPER_JAR), '--nogui'], { cwd: SERVER, stdio: ['pipe', 'inherit', 'inherit'] });
|
|
435
435
|
proc.on('exit', code => { warn(`Server exited (${code})`); if (wss) wss.close(); process.exit(0); });
|
|
@@ -468,6 +468,20 @@ async function runHeadless() {
|
|
|
468
468
|
const log = OUTFILE ? createWriteStream(OUTFILE, { flags: 'a' }) : null;
|
|
469
469
|
const out = (line) => { if (log) log.write(line + '\n'); else console.log(line); };
|
|
470
470
|
|
|
471
|
+
// 流程级超时:覆盖下载/初始化/启动/加载全程(--timeout,默认 2m)
|
|
472
|
+
let done = false;
|
|
473
|
+
const finish = (code) => {
|
|
474
|
+
if (waitTimer) clearTimeout(waitTimer);
|
|
475
|
+
try { if (log) log.end(); } catch {}
|
|
476
|
+
process.exit(code);
|
|
477
|
+
};
|
|
478
|
+
const failTimer = setTimeout(() => {
|
|
479
|
+
if (done) return;
|
|
480
|
+
fail(`流程在 ${TIMEOUT}s 内未完成加载——请检查网络/依赖下载,或加大超时(--timeout=3m)`);
|
|
481
|
+
killProc();
|
|
482
|
+
finish(1);
|
|
483
|
+
}, TIMEOUT * 1000);
|
|
484
|
+
|
|
471
485
|
info('正在下载/准备服务端…');
|
|
472
486
|
await ensurePaper();
|
|
473
487
|
mkdirSync(SERVER, { recursive: true });
|
|
@@ -478,18 +492,14 @@ async function runHeadless() {
|
|
|
478
492
|
copyToYeowDir(resolve(ROOT, 'dist', 'plugins', `${cfg.name}-${cfg.version}.yeow.zip`), 'Plugin (.yeow.zip → plugins/Yeow/)');
|
|
479
493
|
copyToPlugins(RUNTIME, 'Runtime');
|
|
480
494
|
|
|
481
|
-
|
|
495
|
+
// 编码:确保子进程 stdout 按 UTF-8 输出(Windows 下避免中文字符乱码)
|
|
496
|
+
const jvmArgs = ['-Xmx4G', '-Xms4G', '-Dfile.encoding=UTF-8', '-Dstdout.encoding=UTF-8',
|
|
497
|
+
'-Dyeow.dev=true', '-Dyeow.ws.port=' + WS_PORT];
|
|
482
498
|
info(`正在启动 Paper ${PAPER_VERSION}...`);
|
|
483
499
|
proc = spawn('java', [...jvmArgs, '-jar', resolve(SERVER, PAPER_JAR), '--nogui'], { cwd: SERVER, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
484
500
|
info(`Server PID: ${proc.pid}`);
|
|
485
501
|
|
|
486
|
-
let started = false,
|
|
487
|
-
const failTimer = setTimeout(() => {
|
|
488
|
-
if (done) return;
|
|
489
|
-
fail(`服务器在 ${TIMEOUT}s 内未完成加载——请检查网络/依赖下载,或加大超时(--timeout=3m)`);
|
|
490
|
-
killProc();
|
|
491
|
-
process.exit(1);
|
|
492
|
-
}, TIMEOUT * 1000);
|
|
502
|
+
let started = false, waitTimer = null;
|
|
493
503
|
|
|
494
504
|
const onLine = (line) => {
|
|
495
505
|
out(line);
|
|
@@ -503,20 +513,17 @@ async function runHeadless() {
|
|
|
503
513
|
info(`加载完成——等待 ${WAIT}s 后命令结束${KEEP ? '(--keep 保留服务器进程)' : '(关闭服务器进程)'}…`);
|
|
504
514
|
waitTimer = setTimeout(() => {
|
|
505
515
|
info(`等待结束。日志${OUTFILE ? ':' + OUTFILE : '输出于上方'};PID=${proc.pid}${KEEP ? '(服务器仍在运行,按需 kill)' : ''}`);
|
|
506
|
-
if (
|
|
507
|
-
|
|
508
|
-
killProc();
|
|
509
|
-
process.exit(0);
|
|
516
|
+
if (!KEEP) killProc();
|
|
517
|
+
finish(0);
|
|
510
518
|
}, WAIT * 1000);
|
|
511
519
|
}
|
|
512
520
|
};
|
|
513
|
-
|
|
514
|
-
if (proc.stderr)
|
|
521
|
+
createInterface({ input: proc.stdout }).on('line', onLine);
|
|
522
|
+
if (proc.stderr) createInterface({ input: proc.stderr }).on('line', (l) => out('[err] ' + l));
|
|
515
523
|
|
|
516
524
|
proc.on('exit', (code) => {
|
|
517
525
|
if (!done) fail(`服务器提前退出(code ${code})——见${OUTFILE ? '日志 ' + OUTFILE : '上方输出'}`);
|
|
518
|
-
|
|
519
|
-
process.exit(1);
|
|
526
|
+
finish(1);
|
|
520
527
|
});
|
|
521
528
|
}
|
|
522
529
|
|