app
JLCPCB Parts Library
Public Made by Adomby adom
Check the JLCPCB / LCSC parts library before you fab — Basic vs Extended tier, LCSC stock and assembly pricing, so you avoid surprise feeder-setup fees. CLI, a Hydrogen app, and a shared backend.
#!/bin/bash
# Daily JLCPCB database update
#
# Downloads a fresh copy of the CDFER database to a staging path,
# then swaps it in and signals the server to reload.
#
# Install as daily cron:
# sudo cp cron/update-db.sh /etc/cron.daily/update-jlcpcb-db
# sudo chmod +x /etc/cron.daily/update-jlcpcb-db
#
# Or add to crontab:
# 0 4 * * * /app/cron/update-db.sh >> /tmp/jlcpcb-update.log 2>&1
set -e
DB_DIR="${JLCPCB_DB_DIR:-/data}"
DB_PATH="${DB_DIR}/jlcpcb-components.sqlite3"
STAGING_PATH="${DB_DIR}/jlcpcb-components-new.sqlite3"
APP_DIR="${APP_DIR:-/app}"
echo "$(date '+%Y-%m-%d %H:%M:%S') Starting JLCPCB database update"
cd "$APP_DIR"
# Download new database to staging path
JLCPCB_DB_PATH="$STAGING_PATH" node setup-db.js --force
# Always rebuild the FTS index against the staged DB before swapping.
# setup-db.js populates it, but we've observed CDFER-shipped FTS tables
# arriving with rowids that don't align with components.rowid (=lcsc),
# which makes MATCH joins land on unrelated rows. This step is the
# fast, authoritative fix — see service/backend/rebuild-fts.cjs.
# Runs against the staging path so a failure doesn't leave the live
# DB in a half-rebuilt state.
echo "$(date '+%Y-%m-%d %H:%M:%S') Rebuilding search_fts against staged DB..."
JLCPCB_DB_PATH="$STAGING_PATH" node "$APP_DIR/rebuild-fts.cjs"
# Atomic swap
mv "$STAGING_PATH" "$DB_PATH"
echo "$(date '+%Y-%m-%d %H:%M:%S') Database swapped. Signaling server to reload..."
# Send SIGHUP to the Node.js server to trigger DB re-open
# (the server.js has a SIGHUP handler that closes and re-opens the DB)
pkill -HUP -f "node server.js" || true
echo "$(date '+%Y-%m-%d %H:%M:%S') Database update complete"