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

View file

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