mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-06-06 08:00:32 +08:00
fix ipc file cannot listen in linux
This commit is contained in:
@@ -44,14 +44,11 @@ if (process.platform === 'win32') {
|
||||
}
|
||||
else {
|
||||
ipcSocketPath = path.join(tmpdir(), `${ipcSocketName}.sock`)
|
||||
if (!fs.existsSync(ipcSocketPath)) {
|
||||
if (process.platform === 'darwin' && !fs.existsSync(ipcSocketPath)) {
|
||||
fs.writeFileSync(ipcSocketPath, '')
|
||||
// 设置权限(Unix)
|
||||
fs.chmodSync(ipcSocketPath, 0o777)
|
||||
}
|
||||
// 设置权限(Unix)
|
||||
fs.chmodSync(
|
||||
ipcSocketPath,
|
||||
0o777
|
||||
)
|
||||
}
|
||||
|
||||
const workers = new Map(); // workerId -> { process, status, restartCount, socket, latestScreenshot, latestScreenshotAt }
|
||||
@@ -443,13 +440,18 @@ new Promise((resolve, reject) => {
|
||||
)
|
||||
reject(err)
|
||||
})
|
||||
server.listen(ipcSocketPath, () => {
|
||||
server.listen(ipcSocketPath, (err) => {
|
||||
console.log(`守护进程服务器运行在端口 ${ipcSocketPath}`);
|
||||
ipcWritePipe.write(
|
||||
JSON.stringify({ type: 'DAEMON_READY' }),
|
||||
(err) => void err
|
||||
)
|
||||
resolve(true)
|
||||
if (!err) {
|
||||
resolve(true)
|
||||
}
|
||||
else {
|
||||
reject(err)
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
@@ -18,18 +18,13 @@ export async function connectToDaemon() {
|
||||
let isConnected = false
|
||||
await new Promise((resolve, reject) => {
|
||||
const ipcSocketName = process.env.GEEKGEEKRUND_PIPE_NAME
|
||||
const ipcSocketPath = process.platform === 'win32'
|
||||
const ipcSocketPath = process.platform === 'win32'
|
||||
? `\\\\.\\pipe\\${ipcSocketName}`
|
||||
: path.join(tmpdir(), `${ipcSocketName}.sock`)
|
||||
if (process.platform !== 'win32' ) {
|
||||
if (!fs.existsSync(ipcSocketPath)) {
|
||||
fs.writeFileSync(ipcSocketPath, '')
|
||||
}
|
||||
if (process.platform === 'darwin' && !fs.existsSync(ipcSocketPath)) {
|
||||
fs.writeFileSync(ipcSocketPath, '')
|
||||
// 设置权限(Unix)
|
||||
fs.chmodSync(
|
||||
ipcSocketPath,
|
||||
0o777
|
||||
)
|
||||
fs.chmodSync(ipcSocketPath, 0o777)
|
||||
}
|
||||
daemonClient.connect(ipcSocketPath, 'localhost', () => {
|
||||
isConnected = true
|
||||
|
||||
Reference in New Issue
Block a user