mirror of
https://github.com/QYG2297248353/IYUUPlus-Windows.git
synced 2025-03-04 11:44:24 +08:00
修复环境变量
This commit is contained in:
parent
44a602116d
commit
e71dda3b67
@ -7,7 +7,8 @@ module.exports = {
|
|||||||
icon: 'iyuu.png',
|
icon: 'iyuu.png',
|
||||||
extraResource: [
|
extraResource: [
|
||||||
'run/',
|
'run/',
|
||||||
'iyuu/'
|
'iyuu/',
|
||||||
|
"run.bat"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
rebuildConfig: {},
|
rebuildConfig: {},
|
||||||
|
1
run.bat
1
run.bat
@ -1,3 +1,4 @@
|
|||||||
|
@echo off
|
||||||
CHCP 65001
|
CHCP 65001
|
||||||
.\run\php-8.3.8-x64\php.exe .\iyuu\windows.php
|
.\run\php-8.3.8-x64\php.exe .\iyuu\windows.php
|
||||||
pause
|
pause
|
@ -1,4 +1,4 @@
|
|||||||
const { spawn, exec } = require('child_process');
|
const { spawn, exec, execFile } = require('child_process');
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const log = require('electron-log')
|
const log = require('electron-log')
|
||||||
@ -24,25 +24,54 @@ function startServer() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const cmdPath = getCmdPath(resourcePath);
|
const cmdPath = getCmdPath(resourcePath);
|
||||||
const args = [path.join(resourcePath, 'iyuu', 'windows.php')];
|
const batPath = path.join(resourcePath, 'run.bat');
|
||||||
const workingDirectory = path.resolve(resourcePath);
|
const workingDirectory = path.resolve(resourcePath);
|
||||||
|
|
||||||
const env = { ...process.env };
|
const env = { ...process.env };
|
||||||
const phpDir = path.dirname(cmdPath);
|
const phpDir = path.dirname(cmdPath);
|
||||||
env.PATH = `${phpDir}${path.delimiter}${env.PATH}`;
|
env.Path = `${phpDir};${env.Path}`;
|
||||||
|
|
||||||
serverProcess = spawn(cmdPath, args, {
|
// serverProcess = exec(`C:\\Windows\\System32\\cmd.exe /c ${batPath}`, {
|
||||||
|
// cwd: workingDirectory,
|
||||||
|
// env: env,
|
||||||
|
// windowsHide: true
|
||||||
|
// }, (error, stdout, stderr) => {
|
||||||
|
// if (error) {
|
||||||
|
// log.error(`[IYUU] 服务启动错误: ${error.message}`);
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// if (stderr) {
|
||||||
|
// log.error(`[IYUU] 服务启动 stderr: ${stderr}`);
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// log.info(`[IYUU] 服务启动成功: ${stdout}`);
|
||||||
|
// });
|
||||||
|
|
||||||
|
serverProcess = execFile('cmd.exe', ['/c', batPath], {
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
stdio: ['inherit', 'pipe', 'inherit'],
|
stdio: 'ignore',
|
||||||
env: env,
|
env: env,
|
||||||
detached: true,
|
windowsHide: true
|
||||||
});
|
});
|
||||||
|
|
||||||
serverProcess.stdout.setEncoding('utf8');
|
// serverProcess = spawn('cmd.exe', ['/c', batPath], {
|
||||||
|
// cwd: workingDirectory,
|
||||||
|
// stdio: 'ignore',
|
||||||
|
// env: env,
|
||||||
|
// detached: true,
|
||||||
|
// windowsHide: true
|
||||||
|
// });
|
||||||
|
|
||||||
|
serverProcess.unref();
|
||||||
|
|
||||||
|
if (serverProcess.stdout) {
|
||||||
|
serverProcess.stdout.setEncoding('utf8');
|
||||||
|
|
||||||
|
serverProcess.stdout.on("data", function (data) {
|
||||||
|
log.info("[IYUU] 服务启动成功");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
serverProcess.stdout.on("data", function (data) {
|
|
||||||
log.info("[IYUU] 服务启动成功");
|
|
||||||
});
|
|
||||||
serverProcess.on("close", function (code) {
|
serverProcess.on("close", function (code) {
|
||||||
log.info("[IYUU] 服务退出:" + code);
|
log.info("[IYUU] 服务退出:" + code);
|
||||||
});
|
});
|
||||||
@ -75,7 +104,9 @@ function stopServer() {
|
|||||||
|
|
||||||
function restartServer() {
|
function restartServer() {
|
||||||
stopServer();
|
stopServer();
|
||||||
startServer();
|
setTimeout(() => {
|
||||||
|
startServer();
|
||||||
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { startServer, stopServer, restartServer };
|
module.exports = { startServer, stopServer, restartServer };
|
Loading…
x
Reference in New Issue
Block a user