Use a constant for the notification file descriptor

This commit is contained in:
Eelco Dolstra 2023-12-15 17:15:58 +01:00
parent 5e52b9d4a2
commit 9d7fb1fb0e
2 changed files with 8 additions and 8 deletions

8
dist/index.js generated vendored
View file

@ -12181,11 +12181,12 @@ async function setUpAutoCache() {
else {
runEnv = process.env;
}
// Start the server.
// Start the server. Once it is ready, it will notify us via file descriptor 3.
const outputPath = `${daemonDir}/daemon.log`;
const output = openSync(outputPath, 'a');
const notifyFd = 3;
const daemon = spawn(daemonBin, [
'--notify-fd', '3',
'--notify-fd', String(notifyFd),
'--listen', coreExports.getInput('listen'),
'--upstream', coreExports.getInput('upstream-cache'),
'--diagnostic-endpoint', coreExports.getInput('diagnostic-endpoint'),
@ -12205,7 +12206,7 @@ async function setUpAutoCache() {
const pidFile = path$1.join(daemonDir, 'daemon.pid');
await fs$2.writeFile(pidFile, `${daemon.pid}`);
await new Promise((resolve, reject) => {
daemon.stdio[3].on('data', (data) => {
daemon.stdio[notifyFd].on('data', (data) => {
if (data.toString().trim() == 'INIT') {
resolve();
}
@ -12233,7 +12234,6 @@ async function notifyAutoCache() {
return;
}
try {
// FIXME: remove this
coreExports.debug(`Indicating workflow start`);
const res = await gotClient.post(`http://${coreExports.getInput('listen')}/api/workflow-start`).json();
coreExports.debug(`back from post`);

View file

@ -113,13 +113,14 @@ async function setUpAutoCache() {
runEnv = process.env;
}
// Start the server.
// Start the server. Once it is ready, it will notify us via file descriptor 3.
const outputPath = `${daemonDir}/daemon.log`;
const output = openSync(outputPath, 'a');
const notifyFd = 3;
const daemon = spawn(
daemonBin,
[
'--notify-fd', '3',
'--notify-fd', String(notifyFd),
'--listen', core.getInput('listen'),
'--upstream', core.getInput('upstream-cache'),
'--diagnostic-endpoint', core.getInput('diagnostic-endpoint'),
@ -145,7 +146,7 @@ async function setUpAutoCache() {
await fs.writeFile(pidFile, `${daemon.pid}`);
await new Promise<void>((resolve, reject) => {
daemon.stdio[3].on('data', (data) => {
daemon.stdio[notifyFd].on('data', (data) => {
if (data.toString().trim() == 'INIT') {
resolve();
}
@ -177,7 +178,6 @@ async function notifyAutoCache() {
}
try {
// FIXME: remove this
core.debug(`Indicating workflow start`);
const res: any = await gotClient.post(`http://${core.getInput('listen')}/api/workflow-start`).json();
core.debug(`back from post`);