mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2026-04-06 07:47:53 +10:00
more binary fixes
This commit is contained in:
@@ -384,15 +384,6 @@ class Binary(ModelWithHealthStats, ModelWithStateMachine):
|
||||
|
||||
return None
|
||||
|
||||
@property
|
||||
def output_dir(self):
|
||||
"""Return the output directory for this binary installation."""
|
||||
from pathlib import Path
|
||||
from django.conf import settings
|
||||
|
||||
DATA_DIR = getattr(settings, 'DATA_DIR', Path.cwd())
|
||||
return Path(DATA_DIR) / 'machines' / str(self.machine_id) / 'binaries' / self.name / str(self.id)
|
||||
|
||||
def update_and_requeue(self, **kwargs):
|
||||
"""
|
||||
Update binary fields and requeue for worker state machine.
|
||||
@@ -424,8 +415,6 @@ class Binary(ModelWithHealthStats, ModelWithStateMachine):
|
||||
# Create output directory
|
||||
output_dir = self.output_dir
|
||||
output_dir.mkdir(parents=True, exist_ok=True)
|
||||
self.output_dir = str(output_dir)
|
||||
self.save()
|
||||
|
||||
# Discover ALL on_Binary__install_* hooks
|
||||
hooks = discover_hooks('Binary', config=config)
|
||||
@@ -452,7 +441,7 @@ class Binary(ModelWithHealthStats, ModelWithStateMachine):
|
||||
hook_kwargs['overrides'] = json.dumps(self.overrides)
|
||||
|
||||
# Run the hook
|
||||
result = run_hook(
|
||||
process = run_hook(
|
||||
hook,
|
||||
output_dir=plugin_output_dir,
|
||||
config=config,
|
||||
@@ -461,11 +450,11 @@ class Binary(ModelWithHealthStats, ModelWithStateMachine):
|
||||
)
|
||||
|
||||
# Background hook (unlikely for binary installation, but handle it)
|
||||
if result is None:
|
||||
if process is None:
|
||||
continue
|
||||
|
||||
# Failed or skipped hook - try next one
|
||||
if result['returncode'] != 0:
|
||||
if process.exit_code != 0:
|
||||
continue
|
||||
|
||||
# Parse JSONL output to check for successful installation
|
||||
|
||||
@@ -18,25 +18,17 @@ const path = require('path');
|
||||
// Add NODE_MODULES_DIR to module resolution paths if set
|
||||
if (process.env.NODE_MODULES_DIR) module.paths.unshift(process.env.NODE_MODULES_DIR);
|
||||
|
||||
// Debug: Check NODE_V8_COVERAGE
|
||||
console.error(`[DEBUG JS START] NODE_V8_COVERAGE=${process.env.NODE_V8_COVERAGE || 'NOT SET'}`);
|
||||
|
||||
// Hook into process.exit to flush V8 coverage (for NODE_V8_COVERAGE support)
|
||||
if (process.env.NODE_V8_COVERAGE) {
|
||||
const originalExit = process.exit.bind(process);
|
||||
process.exit = function(code) {
|
||||
console.error(`[DEBUG] process.exit() override called with code=${code}`);
|
||||
// Flush V8 coverage before exiting (for NODE_V8_COVERAGE support)
|
||||
function flushCoverageAndExit(exitCode) {
|
||||
if (process.env.NODE_V8_COVERAGE) {
|
||||
try {
|
||||
const v8 = require('v8');
|
||||
const result = v8.takeCoverage();
|
||||
console.error(`[DEBUG] v8.takeCoverage() returned: ${typeof result}`);
|
||||
v8.takeCoverage();
|
||||
} catch (e) {
|
||||
// Log but don't block exit - we're exiting anyway
|
||||
console.error(`[!] Coverage flush failed: ${e.message}`);
|
||||
// Ignore errors during coverage flush
|
||||
}
|
||||
originalExit(code);
|
||||
};
|
||||
console.error('[DEBUG] process.exit() override installed');
|
||||
}
|
||||
process.exit(exitCode);
|
||||
}
|
||||
|
||||
const {
|
||||
@@ -51,7 +43,7 @@ const {
|
||||
if (!getEnvBool('SCREENSHOT_ENABLED', true)) {
|
||||
console.error('Skipping screenshot (SCREENSHOT_ENABLED=False)');
|
||||
// Temporary failure (config disabled) - NO JSONL emission
|
||||
process.exit(0);
|
||||
flushCoverageAndExit(0);
|
||||
}
|
||||
|
||||
// Now safe to require puppeteer
|
||||
|
||||
Reference in New Issue
Block a user