@hatk/hatk 0.0.1-alpha.12 → 0.0.1-alpha.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config.js +1 -1
- package/dist/db.js +2 -2
- package/dist/fts.d.ts.map +1 -1
- package/dist/fts.js +5 -0
- package/dist/main.js +8 -0
- package/package.json +1 -1
package/dist/config.js
CHANGED
|
@@ -27,7 +27,7 @@ export function loadConfig(configPath) {
|
|
|
27
27
|
fetchTimeout: parseInt(env.BACKFILL_FETCH_TIMEOUT || '') || backfillRaw.fetchTimeout || 300,
|
|
28
28
|
maxRetries: parseInt(env.BACKFILL_MAX_RETRIES || '') || backfillRaw.maxRetries || 5,
|
|
29
29
|
},
|
|
30
|
-
ftsRebuildInterval: parseInt(env.FTS_REBUILD_INTERVAL || '') || parsed.ftsRebuildInterval ||
|
|
30
|
+
ftsRebuildInterval: parseInt(env.FTS_REBUILD_INTERVAL || '') || parsed.ftsRebuildInterval || 5000,
|
|
31
31
|
oauth: null,
|
|
32
32
|
admins: env.ADMINS ? env.ADMINS.split(',').map((s) => s.trim()) : parsed.admins || [],
|
|
33
33
|
};
|
package/dist/db.js
CHANGED
|
@@ -115,8 +115,8 @@ async function all(sql, ...params) {
|
|
|
115
115
|
}
|
|
116
116
|
export async function initDatabase(dbPath, tableSchemas, ddlStatements) {
|
|
117
117
|
instance = await DuckDBInstance.create(dbPath === ':memory:' ? undefined : dbPath, {
|
|
118
|
-
memory_limit: '
|
|
119
|
-
threads: '
|
|
118
|
+
memory_limit: '256MB',
|
|
119
|
+
threads: '1',
|
|
120
120
|
});
|
|
121
121
|
con = await instance.connect();
|
|
122
122
|
readCon = await instance.connect();
|
package/dist/fts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fts.d.ts","sourceRoot":"","sources":["../src/fts.ts"],"names":[],"mappings":"AAwEA,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAE7D;AAED,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAElE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA0FrE;AAokBD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIpD;AAED,wBAAsB,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"fts.d.ts","sourceRoot":"","sources":["../src/fts.ts"],"names":[],"mappings":"AAwEA,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAE7D;AAED,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAElE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA0FrE;AAokBD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIpD;AAED,wBAAsB,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA0B5E"}
|
package/dist/fts.js
CHANGED
|
@@ -752,6 +752,11 @@ export async function rebuildAllIndexes(collections) {
|
|
|
752
752
|
errors.push(`${collection}: ${err.message}`);
|
|
753
753
|
}
|
|
754
754
|
}
|
|
755
|
+
// Compact WAL to free DuckDB memory after heavy FTS operations
|
|
756
|
+
try {
|
|
757
|
+
await runSQL('CHECKPOINT');
|
|
758
|
+
}
|
|
759
|
+
catch { }
|
|
755
760
|
emit('fts', 'rebuild', {
|
|
756
761
|
collections_total: collections.length,
|
|
757
762
|
collections_rebuilt: rebuilt,
|
package/dist/main.js
CHANGED
|
@@ -19,8 +19,13 @@ import { runBackfill } from "./backfill.js";
|
|
|
19
19
|
import { initOAuth } from "./oauth/server.js";
|
|
20
20
|
import { loadOnLoginHook } from "./oauth/hooks.js";
|
|
21
21
|
import { initSetup } from "./setup.js";
|
|
22
|
+
function logMemory(phase) {
|
|
23
|
+
const mem = process.memoryUsage();
|
|
24
|
+
log(`[mem] ${phase}: heap=${Math.round(mem.heapUsed / 1024 / 1024)}MB rss=${Math.round(mem.rss / 1024 / 1024)}MB external=${Math.round(mem.external / 1024 / 1024)}MB arrayBuffers=${Math.round(mem.arrayBuffers / 1024 / 1024)}MB`);
|
|
25
|
+
}
|
|
22
26
|
const configPath = process.argv[2] || 'config.yaml';
|
|
23
27
|
const configDir = dirname(resolve(configPath));
|
|
28
|
+
logMemory('startup');
|
|
24
29
|
// 1. Load config
|
|
25
30
|
const config = loadConfig(configPath);
|
|
26
31
|
configureRelay(config.relay);
|
|
@@ -74,6 +79,7 @@ if (config.database !== ':memory:') {
|
|
|
74
79
|
mkdirSync(dirname(config.database), { recursive: true });
|
|
75
80
|
}
|
|
76
81
|
await initDatabase(config.database, schemas, ddlStatements);
|
|
82
|
+
logMemory('after-db-init');
|
|
77
83
|
log(`[main] DuckDB initialized (${config.database === ':memory:' ? 'in-memory' : config.database})`);
|
|
78
84
|
// 3b. Run setup hooks (after DB init, before server)
|
|
79
85
|
await initSetup(resolve(configDir, 'setup'));
|
|
@@ -104,6 +110,7 @@ if (config.oauth) {
|
|
|
104
110
|
await initOAuth(config.oauth, config.plc, config.relay);
|
|
105
111
|
log(`[main] OAuth initialized (issuer: ${config.oauth.issuer})`);
|
|
106
112
|
}
|
|
113
|
+
logMemory('before-server');
|
|
107
114
|
// 5. Start server immediately (don't wait for backfill)
|
|
108
115
|
const collectionSet = new Set(collections);
|
|
109
116
|
startServer(config.port, collections, config.publicDir, config.oauth, config.admins);
|
|
@@ -115,6 +122,7 @@ log(` Collections: ${collections.join(', ')}`);
|
|
|
115
122
|
log(` Feeds: ${listFeeds()
|
|
116
123
|
.map((f) => f.name)
|
|
117
124
|
.join(', ')}`);
|
|
125
|
+
logMemory('after-server');
|
|
118
126
|
// 6. Start indexer with cursor
|
|
119
127
|
const cursor = await getCursor('relay');
|
|
120
128
|
startIndexer({
|