fix: serialize autonomy job leases
This commit is contained in:
@@ -71,6 +71,7 @@ async function runAutonomyWorker({ archivePath, intelligencePath, workerId = `au
|
||||
const archiveDb = new Database(archivePath, { readonly: true });
|
||||
const intelligenceDb = new Database(intelligencePath);
|
||||
intelligenceDb.pragma('journal_mode = WAL');
|
||||
intelligenceDb.pragma('busy_timeout = 5000');
|
||||
initAutonomySchema(intelligenceDb);
|
||||
|
||||
while (true) {
|
||||
|
||||
@@ -71,6 +71,7 @@ function createDecisions(db, strategyVersion = 'autonomy-1') {
|
||||
async function runCalibrationWorker({ intelligencePath, pollMs = 60000, workerId = `calibration-${os.hostname()}-${process.pid}` } = {}) {
|
||||
const db = new Database(intelligencePath);
|
||||
db.pragma('journal_mode = WAL');
|
||||
db.pragma('busy_timeout = 5000');
|
||||
initAutonomySchema(db);
|
||||
while (true) {
|
||||
try {
|
||||
|
||||
@@ -34,6 +34,7 @@ async function runCoordinatorWorker({ archivePath, intelligencePath, workerId =
|
||||
const archiveDb = new Database(archivePath, { readonly: true });
|
||||
const intelligenceDb = new Database(intelligencePath);
|
||||
intelligenceDb.pragma('journal_mode = WAL');
|
||||
intelligenceDb.pragma('busy_timeout = 5000');
|
||||
initAutonomySchema(intelligenceDb);
|
||||
const config = loadConfig();
|
||||
while (true) {
|
||||
|
||||
@@ -10,6 +10,7 @@ async function runExecutionWorker({ intelligencePath, pollMs = 10000, mode = 'sh
|
||||
if (!['shadow', 'paper'].includes(mode)) throw new Error(`unsupported execution mode: ${mode}`);
|
||||
const db = new Database(intelligencePath);
|
||||
db.pragma('journal_mode = WAL');
|
||||
db.pragma('busy_timeout = 5000');
|
||||
initAutonomySchema(db);
|
||||
const paperClient = mode === 'paper'
|
||||
? createAlpacaPaperClient({ keyId: process.env.ALPACA_PAPER_KEY_ID, secretKey: process.env.ALPACA_PAPER_SECRET_KEY })
|
||||
|
||||
@@ -33,6 +33,7 @@ async function history(symbol) {
|
||||
async function resolveAutonomyOutcomes({ intelligencePath, workerId = `outcome-${os.hostname()}-${process.pid}`, pollMs = 60000 } = {}) {
|
||||
const db = new Database(intelligencePath);
|
||||
db.pragma('journal_mode = WAL');
|
||||
db.pragma('busy_timeout = 5000');
|
||||
initAutonomySchema(db);
|
||||
const cache = new Map();
|
||||
while (true) {
|
||||
|
||||
Reference in New Issue
Block a user