Skip to content

Commit

Permalink
Merge pull request #30 from DeterminateSystems/get-cache-log
Browse files Browse the repository at this point in the history
Correct cache log
  • Loading branch information
grahamc authored Feb 1, 2024
2 parents 1402a2d + 879f4f5 commit 80b14c9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
16 changes: 10 additions & 6 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 9 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import * as fs from 'node:fs/promises';
import * as os from 'node:os';
import * as path from 'node:path';
import { spawn } from 'node:child_process';
import { createWriteStream, openSync, writeSync, close } from 'node:fs';
import { createWriteStream, openSync, writeSync, close, readFileSync } from 'node:fs';
import { pipeline } from 'node:stream/promises';
import { setTimeout } from 'timers/promises';
import { inspect } from 'node:util';

import * as core from '@actions/core';
Expand All @@ -17,7 +16,7 @@ const ENV_CACHE_DAEMONDIR = 'MAGIC_NIX_CACHE_DAEMONDIR';

const gotClient = got.extend({
retry: {
limit: 5,
limit: 1,
methods: [ 'POST', 'GET', 'PUT', 'HEAD', 'DELETE', 'OPTIONS', 'TRACE' ],
},
hooks: {
Expand Down Expand Up @@ -113,7 +112,7 @@ async function setUpAutoCache() {
runEnv = process.env;
}

const output = openSync(`${daemonDir}/parent.log`, 'a');
const output = openSync(`${daemonDir}/daemon.log`, 'a');
const launch = spawn(
daemonBin,
[
Expand Down Expand Up @@ -187,7 +186,6 @@ async function tearDownAutoCache() {
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);
});

Expand All @@ -198,8 +196,6 @@ async function tearDownAutoCache() {
core.debug(`back from post`);
core.debug(res);
} finally {
await setTimeout(5000);

core.debug(`unwatching the daemon log`);
log.unwatch();
}
Expand All @@ -211,6 +207,12 @@ async function tearDownAutoCache() {
if (e.code !== 'ESRCH') {
throw e;
}
} finally {
if (core.isDebug()) {
core.info("Entire log:");
const log = readFileSync(path.join(daemonDir, 'daemon.log'));
core.info(log.toString());
}
}
}

Expand Down

0 comments on commit 80b14c9

Please sign in to comment.