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