Downline Banners data in MySQL (Marty 2026-11-13: database is the standard): docstore.js (same file as LinkSpin/InstantAdPay) keeps store.json, refuel spots, hub report and sign-in nonces in MySQL (DOCSTORE_URL), one writer at a time; startup waits for the store before loading anything. chain-index.json stays a rebuildable cache, art/ uploads stay files. Smoke 76/76.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-13 09:38:51 -06:00
parent 9408b7af8b
commit c6ca40a241
4 changed files with 317 additions and 9 deletions
+11 -6
View File
@@ -20,11 +20,7 @@ const SEL = { buy: iface.getFunction('buy').selector, buyFor: iface.getFunction(
const C = cfgMod.get();
fs.mkdirSync(path.join(C.dataDir, 'art'), { recursive: true });
store.load();
chain.init();
hubreport.init({ dataDir: C.dataDir, members: () => chain.allMembers() });
refuelspots.init({ lock: () => keeper.busy() }); keeper.setOtherBusy(() => refuelspots.busy());
keeper.init();
const docstore = require('./docstore'); docstore.install(C.dataDir); // data documents live in MySQL when DOCSTORE_URL is set (Marty 2026-11-13: database is the standard)
const PUB = path.join(__dirname, 'public');
const ADDR_RE = /^0x[0-9a-fA-F]{40}$/;
@@ -389,6 +385,15 @@ const server = http.createServer(async (req, res) => {
}
});
server.listen(C.port, () => console.log('Downline Banners on :' + C.port + ' chain ' + C.chainName + ' (' + C.chainId + ') contract ' + (C.contract || '(not set)')));
(async () => {
await docstore.init({}); // before anything reads its data
process.on('SIGTERM', () => { docstore.drain(8000).finally(() => process.exit(0)); });
store.load();
chain.init();
hubreport.init({ dataDir: C.dataDir, members: () => chain.allMembers() });
refuelspots.init({ lock: () => keeper.busy() }); keeper.setOtherBusy(() => refuelspots.busy());
keeper.init();
server.listen(C.port, () => console.log('Downline Banners on :' + C.port + ' chain ' + C.chainName + ' (' + C.chainId + ') contract ' + (C.contract || '(not set)') + ' store: ' + (docstore.isOn() ? 'MySQL documents' : 'volume JSON')));
})().catch(e => { console.error('start failed:', e.message); process.exit(1); });
process.on('SIGTERM', () => { store.flush(); process.exit(0); });
process.on('SIGINT', () => { store.flush(); process.exit(0); });