Skip to content

Commit

Permalink
avoid fork
Browse files Browse the repository at this point in the history
  • Loading branch information
p0deje committed May 31, 2024
1 parent d5146b7 commit 3199021
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
10 changes: 6 additions & 4 deletions dist/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96872,7 +96872,7 @@ const github = __nccwpck_require__(5438)
const glob = __nccwpck_require__(8090)
const tc = __nccwpck_require__(7784)
const config = __nccwpck_require__(5532)
const { fork } = __nccwpck_require__(2081)
const { spawn } = __nccwpck_require__(2081)
const path = __nccwpck_require__(1017)

async function run() {
Expand Down Expand Up @@ -97049,14 +97049,16 @@ async function startRemoteCacheServer() {

core.info(`Remote cache server log file path: ${config.remoteCacheServer.logPath}`)
const log = fs.openSync(config.remoteCacheServer.logPath, 'a')
const serverProcess = fork(path.join(__dirname, '..', 'remote-cache-server', 'index.js'), [], {
const remoteCacheServer = path.join(__dirname, '..', 'remote-cache-server', 'index.js')
const serverProcess = spawn(process.execPath, [remoteCacheServer], {
detached: true,
stdio: ['ignore', log, log, 'ipc']
stdio: ['ignore', log, log]
})
serverProcess.unref()

core.info(`Started remote cache server (${serverProcess.pid})`)
core.saveState('remote-cache-server-pid', serverProcess.pid.toString())

serverProcess.unref()
core.endGroup()
}

Expand Down
2 changes: 1 addition & 1 deletion dist/main/index.js.map

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const github = require('@actions/github')
const glob = require('@actions/glob')
const tc = require('@actions/tool-cache')
const config = require('./config')
const { fork } = require('child_process')
const { spawn } = require('child_process')
const path = require('path')

async function run() {
Expand Down Expand Up @@ -183,14 +183,16 @@ async function startRemoteCacheServer() {

core.info(`Remote cache server log file path: ${config.remoteCacheServer.logPath}`)
const log = fs.openSync(config.remoteCacheServer.logPath, 'a')
const serverProcess = fork(path.join(__dirname, '..', 'remote-cache-server', 'index.js'), [], {
const remoteCacheServer = path.join(__dirname, '..', 'remote-cache-server', 'index.js')
const serverProcess = spawn(process.execPath, [remoteCacheServer], {
detached: true,
stdio: ['ignore', log, log, 'ipc']
stdio: ['ignore', log, log]
})
serverProcess.unref()

core.info(`Started remote cache server (${serverProcess.pid})`)
core.saveState('remote-cache-server-pid', serverProcess.pid.toString())

serverProcess.unref()
core.endGroup()
}

Expand Down

0 comments on commit 3199021

Please sign in to comment.