Fix directory structure: outputs/ for logs, runfiles/ for codex execution
This commit is contained in:
parent
488e7a5db8
commit
9a3530fe66
20
run.php
20
run.php
@ -27,8 +27,12 @@ if ($argc > 2 && is_numeric($argv[2])) {
|
||||
}
|
||||
}
|
||||
|
||||
// NEW: Use runfiles subdirectory
|
||||
$baseOutputDir = 'runfiles';
|
||||
// NEW: Create runfiles subdirectory for codex execution
|
||||
$runfilesDir = 'runfiles';
|
||||
is_dir($runfilesDir) || mkdir($runfilesDir, 0777, true);
|
||||
|
||||
// Outputs directory for logs and summaries (as before)
|
||||
$baseOutputDir = 'outputs';
|
||||
is_dir($baseOutputDir) || mkdir($baseOutputDir, 0777, true);
|
||||
$runIdentifier = date('Ymd_His');
|
||||
$runDir = sprintf('%s/run_%s', $baseOutputDir, $runIdentifier);
|
||||
@ -49,10 +53,15 @@ $logCli = function ($message, $channel = 'global') use (&$logFiles, $rawLogsDir)
|
||||
echo $message;
|
||||
};
|
||||
$logCli(sprintf("[%s] Run initialized in %s%s", date('Y-m-d H:i:s'), $runDir, PHP_EOL), 'startup');
|
||||
$logCli(sprintf("[%s] Codex execution directory: %s%s", date('Y-m-d H:i:s'), realpath($runfilesDir), PHP_EOL), 'startup');
|
||||
if ($startFrom > 1) {
|
||||
$logCli(sprintf("[%s] Starting from input line %d%s", date('Y-m-d H:i:s'), $startFrom, PHP_EOL), 'startup');
|
||||
}
|
||||
$runCommand = function ($command, $channel = 'global') use ($logCli) {
|
||||
$runCommand = function ($command, $channel = 'global') use ($logCli, $runfilesDir) {
|
||||
// Change to runfiles directory for execution
|
||||
$originalDir = getcwd();
|
||||
chdir($runfilesDir);
|
||||
|
||||
$descriptorSpec = [
|
||||
0 => ['pipe', 'r'],
|
||||
1 => ['pipe', 'w'],
|
||||
@ -60,6 +69,7 @@ $runCommand = function ($command, $channel = 'global') use ($logCli) {
|
||||
];
|
||||
$process = proc_open($command, $descriptorSpec, $pipes);
|
||||
if (!is_resource($process)) {
|
||||
chdir($originalDir);
|
||||
$logCli(sprintf("Failed to start command: %s%s", $command, PHP_EOL), $channel);
|
||||
return ['', '', 1];
|
||||
}
|
||||
@ -126,6 +136,10 @@ $runCommand = function ($command, $channel = 'global') use ($logCli) {
|
||||
}
|
||||
|
||||
$exitCode = proc_close($process);
|
||||
|
||||
// Change back to original directory
|
||||
chdir($originalDir);
|
||||
|
||||
return [$stdout, $stderr, $exitCode];
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user