Skip to content

Commit 80b14c9

Browse files
authored
Merge pull request #30 from DeterminateSystems/get-cache-log
Correct cache log
2 parents 1402a2d + 879f4f5 commit 80b14c9

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

dist/index.js

+10-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

+9-7
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ import * as fs from 'node:fs/promises';
44
import * as os from 'node:os';
55
import * as path from 'node:path';
66
import { spawn } from 'node:child_process';
7-
import { createWriteStream, openSync, writeSync, close } from 'node:fs';
7+
import { createWriteStream, openSync, writeSync, close, readFileSync } from 'node:fs';
88
import { pipeline } from 'node:stream/promises';
9-
import { setTimeout } from 'timers/promises';
109
import { inspect } from 'node:util';
1110

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

1817
const gotClient = got.extend({
1918
retry: {
20-
limit: 5,
19+
limit: 1,
2120
methods: [ 'POST', 'GET', 'PUT', 'HEAD', 'DELETE', 'OPTIONS', 'TRACE' ],
2221
},
2322
hooks: {
@@ -113,7 +112,7 @@ async function setUpAutoCache() {
113112
runEnv = process.env;
114113
}
115114

116-
const output = openSync(`${daemonDir}/parent.log`, 'a');
115+
const output = openSync(`${daemonDir}/daemon.log`, 'a');
117116
const launch = spawn(
118117
daemonBin,
119118
[
@@ -187,7 +186,6 @@ async function tearDownAutoCache() {
187186
const log = new Tail(path.join(daemonDir, 'daemon.log'));
188187
core.debug(`tailing daemon.log...`);
189188
log.on('line', (line) => {
190-
core.debug(`got a log line`);
191189
core.info(line);
192190
});
193191

@@ -198,8 +196,6 @@ async function tearDownAutoCache() {
198196
core.debug(`back from post`);
199197
core.debug(res);
200198
} finally {
201-
await setTimeout(5000);
202-
203199
core.debug(`unwatching the daemon log`);
204200
log.unwatch();
205201
}
@@ -211,6 +207,12 @@ async function tearDownAutoCache() {
211207
if (e.code !== 'ESRCH') {
212208
throw e;
213209
}
210+
} finally {
211+
if (core.isDebug()) {
212+
core.info("Entire log:");
213+
const log = readFileSync(path.join(daemonDir, 'daemon.log'));
214+
core.info(log.toString());
215+
}
214216
}
215217
}
216218

0 commit comments

Comments
 (0)