mirror of
https://github.com/DeterminateSystems/magic-nix-cache-action.git
synced 2024-12-27 01:30:35 +01:00
Show daemon log output in setup
This commit is contained in:
parent
35b2e152f0
commit
124dc2196d
2 changed files with 32 additions and 21 deletions
25
dist/index.js
generated
vendored
25
dist/index.js
generated
vendored
|
@ -12146,6 +12146,15 @@ async function fetchAutoCacher() {
|
||||||
const last_path = paths.at(-2);
|
const last_path = paths.at(-2);
|
||||||
return `${last_path}/bin/magic-nix-cache`;
|
return `${last_path}/bin/magic-nix-cache`;
|
||||||
}
|
}
|
||||||
|
function tailLog(daemonDir) {
|
||||||
|
const log = new Tail_1(path$1.join(daemonDir, 'daemon.log'));
|
||||||
|
coreExports.debug(`tailing daemon.log...`);
|
||||||
|
log.on('line', (line) => {
|
||||||
|
//core.debug(`got a log line`);
|
||||||
|
coreExports.info(line);
|
||||||
|
});
|
||||||
|
return log;
|
||||||
|
}
|
||||||
async function setUpAutoCache() {
|
async function setUpAutoCache() {
|
||||||
const tmpdir = process.env['RUNNER_TEMP'] || os$2.tmpdir();
|
const tmpdir = process.env['RUNNER_TEMP'] || os$2.tmpdir();
|
||||||
const required_env = ['ACTIONS_CACHE_URL', 'ACTIONS_RUNTIME_URL', 'ACTIONS_RUNTIME_TOKEN'];
|
const required_env = ['ACTIONS_CACHE_URL', 'ACTIONS_RUNTIME_URL', 'ACTIONS_RUNTIME_TOKEN'];
|
||||||
|
@ -12182,6 +12191,7 @@ async function setUpAutoCache() {
|
||||||
// Start the server. Once it is ready, it will notify us via file descriptor 3.
|
// 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 log = tailLog(daemonDir);
|
||||||
const notifyFd = 3;
|
const notifyFd = 3;
|
||||||
const daemon = spawn(daemonBin, [
|
const daemon = spawn(daemonBin, [
|
||||||
'--notify-fd', String(notifyFd),
|
'--notify-fd', String(notifyFd),
|
||||||
|
@ -12210,21 +12220,21 @@ async function setUpAutoCache() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
daemon.on('exit', async (code, signal) => {
|
daemon.on('exit', async (code, signal) => {
|
||||||
const log = await fs$2.readFile(outputPath, 'utf-8');
|
|
||||||
if (signal) {
|
if (signal) {
|
||||||
reject(new Error(`Daemon was killed by signal ${signal}: ${log}`));
|
reject(new Error(`Daemon was killed by signal ${signal}`));
|
||||||
}
|
}
|
||||||
else if (code) {
|
else if (code) {
|
||||||
reject(new Error(`Daemon exited with code ${code}: ${log}`));
|
reject(new Error(`Daemon exited with code ${code}`));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
reject(new Error(`Daemon unexpectedly exited: ${log}`));
|
reject(new Error(`Daemon unexpectedly exited`));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
daemon.unref();
|
daemon.unref();
|
||||||
coreExports.info('Launched Magic Nix Cache');
|
coreExports.info('Launched Magic Nix Cache');
|
||||||
coreExports.exportVariable(ENV_CACHE_DAEMONDIR, daemonDir);
|
coreExports.exportVariable(ENV_CACHE_DAEMONDIR, daemonDir);
|
||||||
|
log.unwatch();
|
||||||
}
|
}
|
||||||
async function notifyAutoCache() {
|
async function notifyAutoCache() {
|
||||||
const daemonDir = process.env[ENV_CACHE_DAEMONDIR];
|
const daemonDir = process.env[ENV_CACHE_DAEMONDIR];
|
||||||
|
@ -12255,12 +12265,7 @@ async function tearDownAutoCache() {
|
||||||
if (!pid) {
|
if (!pid) {
|
||||||
throw new Error("magic-nix-cache did not start successfully");
|
throw new Error("magic-nix-cache did not start successfully");
|
||||||
}
|
}
|
||||||
const log = new Tail_1(path$1.join(daemonDir, 'daemon.log'));
|
const log = tailLog(daemonDir);
|
||||||
coreExports.debug(`tailing daemon.log...`);
|
|
||||||
log.on('line', (line) => {
|
|
||||||
coreExports.debug(`got a log line`);
|
|
||||||
coreExports.info(line);
|
|
||||||
});
|
|
||||||
try {
|
try {
|
||||||
coreExports.debug(`about to post to localhost`);
|
coreExports.debug(`about to post to localhost`);
|
||||||
const res = await gotClient.post(`http://${coreExports.getInput('listen')}/api/workflow-finish`).json();
|
const res = await gotClient.post(`http://${coreExports.getInput('listen')}/api/workflow-finish`).json();
|
||||||
|
|
28
src/index.ts
28
src/index.ts
|
@ -72,6 +72,16 @@ async function fetchAutoCacher() {
|
||||||
return `${last_path}/bin/magic-nix-cache`;
|
return `${last_path}/bin/magic-nix-cache`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function tailLog(daemonDir) {
|
||||||
|
const log = new Tail(path.join(daemonDir, 'daemon.log'));
|
||||||
|
core.debug(`tailing daemon.log...`);
|
||||||
|
log.on('line', (line) => {
|
||||||
|
//core.debug(`got a log line`);
|
||||||
|
core.info(line);
|
||||||
|
});
|
||||||
|
return log;
|
||||||
|
}
|
||||||
|
|
||||||
async function setUpAutoCache() {
|
async function setUpAutoCache() {
|
||||||
const tmpdir = process.env['RUNNER_TEMP'] || os.tmpdir();
|
const tmpdir = process.env['RUNNER_TEMP'] || os.tmpdir();
|
||||||
const required_env = ['ACTIONS_CACHE_URL', 'ACTIONS_RUNTIME_URL', 'ACTIONS_RUNTIME_TOKEN'];
|
const required_env = ['ACTIONS_CACHE_URL', 'ACTIONS_RUNTIME_URL', 'ACTIONS_RUNTIME_TOKEN'];
|
||||||
|
@ -113,6 +123,7 @@ async function setUpAutoCache() {
|
||||||
// Start the server. Once it is ready, it will notify us via file descriptor 3.
|
// 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 log = tailLog(daemonDir);
|
||||||
const notifyFd = 3;
|
const notifyFd = 3;
|
||||||
const daemon = spawn(
|
const daemon = spawn(
|
||||||
daemonBin,
|
daemonBin,
|
||||||
|
@ -150,13 +161,12 @@ async function setUpAutoCache() {
|
||||||
});
|
});
|
||||||
|
|
||||||
daemon.on('exit', async (code, signal) => {
|
daemon.on('exit', async (code, signal) => {
|
||||||
const log: string = await fs.readFile(outputPath, 'utf-8');
|
|
||||||
if (signal) {
|
if (signal) {
|
||||||
reject(new Error(`Daemon was killed by signal ${signal}: ${log}`));
|
reject(new Error(`Daemon was killed by signal ${signal}`));
|
||||||
} else if (code) {
|
} else if (code) {
|
||||||
reject(new Error(`Daemon exited with code ${code}: ${log}`));
|
reject(new Error(`Daemon exited with code ${code}`));
|
||||||
} else {
|
} else {
|
||||||
reject(new Error(`Daemon unexpectedly exited: ${log}`));
|
reject(new Error(`Daemon unexpectedly exited`));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -165,6 +175,8 @@ async function setUpAutoCache() {
|
||||||
|
|
||||||
core.info('Launched Magic Nix Cache');
|
core.info('Launched Magic Nix Cache');
|
||||||
core.exportVariable(ENV_CACHE_DAEMONDIR, daemonDir);
|
core.exportVariable(ENV_CACHE_DAEMONDIR, daemonDir);
|
||||||
|
|
||||||
|
log.unwatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function notifyAutoCache() {
|
async function notifyAutoCache() {
|
||||||
|
@ -201,13 +213,7 @@ async function tearDownAutoCache() {
|
||||||
throw new Error("magic-nix-cache did not start successfully");
|
throw new Error("magic-nix-cache did not start successfully");
|
||||||
}
|
}
|
||||||
|
|
||||||
const log = new Tail(path.join(daemonDir, 'daemon.log'));
|
const log = tailLog(daemonDir);
|
||||||
core.debug(`tailing daemon.log...`);
|
|
||||||
log.on('line', (line) => {
|
|
||||||
core.debug(`got a log line`);
|
|
||||||
core.info(line);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
core.debug(`about to post to localhost`);
|
core.debug(`about to post to localhost`);
|
||||||
|
|
Loading…
Reference in a new issue