mirror of
https://github.com/tale/headplane.git
synced 2026-08-27 15:37:04 +00:00
fix: attempt to auto create agent work_dir if missing
This commit is contained in:
+34
-4
@@ -1,6 +1,13 @@
|
|||||||
import { ChildProcess, spawn } from 'node:child_process';
|
import { ChildProcess, spawn } from 'node:child_process';
|
||||||
import { createHash } from 'node:crypto';
|
import { createHash } from 'node:crypto';
|
||||||
import { constants, access, open, readFile, writeFile } from 'node:fs/promises';
|
import {
|
||||||
|
constants,
|
||||||
|
access,
|
||||||
|
mkdir,
|
||||||
|
open,
|
||||||
|
readFile,
|
||||||
|
writeFile,
|
||||||
|
} from 'node:fs/promises';
|
||||||
import { exit } from 'node:process';
|
import { exit } from 'node:process';
|
||||||
import { createInterface } from 'node:readline';
|
import { createInterface } from 'node:readline';
|
||||||
import { setTimeout } from 'node:timers/promises';
|
import { setTimeout } from 'node:timers/promises';
|
||||||
@@ -49,9 +56,32 @@ export async function loadAgentSocket(
|
|||||||
await access(config.work_dir, constants.R_OK | constants.W_OK);
|
await access(config.work_dir, constants.R_OK | constants.W_OK);
|
||||||
log.debug('config', 'Using agent work dir at %s', config.work_dir);
|
log.debug('config', 'Using agent work dir at %s', config.work_dir);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.info('config', 'Agent work dir not accessible at %s', config.work_dir);
|
// Try to create the directory just in case
|
||||||
log.debug('config', 'Error details: %s', error);
|
try {
|
||||||
return;
|
await mkdir(config.work_dir, { recursive: true });
|
||||||
|
log.debug('config', 'Created agent work dir at %s', config.work_dir);
|
||||||
|
log.info(
|
||||||
|
'config',
|
||||||
|
'Created missing agent work dir at %s',
|
||||||
|
config.work_dir,
|
||||||
|
);
|
||||||
|
|
||||||
|
return;
|
||||||
|
} catch (innerError) {
|
||||||
|
log.error(
|
||||||
|
'config',
|
||||||
|
'Failed to create agent work dir at %s',
|
||||||
|
config.work_dir,
|
||||||
|
);
|
||||||
|
log.info(
|
||||||
|
'config',
|
||||||
|
'Agent work dir not accessible at %s',
|
||||||
|
config.work_dir,
|
||||||
|
);
|
||||||
|
log.debug('config', 'Error details: %s', error);
|
||||||
|
log.debug('config', 'Create error details: %s', innerError);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user