Files
c-relay-pg/deploy_debug.log
T
Laan Tungir 50653dc86a v2.1.38 - Custom backfill feature: ad-hoc backfill jobs with arbitrary NIP-01 filters + admin UI isolation
- New caching_custom_backfill_jobs and caching_custom_backfill_batches tables
- Admin API (POST create/cancel, GET list) at admin/api/custom_backfill.php
- Admin UI form with preset buttons and job status table on Backfill page
- Caching daemon module (custom_backfill.c) processes jobs independently
- pg_inbox functions for job/batch claim, progress update, and cancel
- Three batch modes: author-batched, id-batched, time-window scan
- Fixed done_batches overcount on job completion
- Admin config now environment-variable driven (C_RELAY_DB_*)
- admin/serve.sh supports separate instances for different databases
- make_and_restart_relay.sh only kills relay on target port, not all relays
2026-08-07 14:49:13 -04:00

193 lines
10 KiB
Plaintext

+ set -euo pipefail
+ LOCAL_BINARY=build/c_relay_pg_static_x86_64
+ LOCAL_CACHING_BINARY=build/caching_relay
+ DEPLOY_DIR=/home/user/Storage/c_relay_pg
+ DEPLOYED_BINARY=/home/user/Storage/c_relay_pg/crelay
+ DEPLOYED_CACHING_BINARY=/home/user/Storage/c_relay_pg/caching_relay
+ SERVICE_NAME=c-relay-pg-local
+ SERVICE_FILE=systemd/c-relay-pg-local.service
+ INSTALLED_SERVICE_PATH=/etc/systemd/system/c-relay-pg-local.service
+ LOCAL_ADMIN_DIR=admin
+ PROD_ADMIN_DIR=admin_prod
+ PROD_ADMIN_PORT=7077
+ DB_HOST=127.0.0.1
+ DB_NAME=crelay_prod
+ DB_USER=crelay
+ DB_PASSWORD=crelay
+ RELAY_PORT=7777
+ RED='\033[0;31m'
+ GREEN='\033[0;32m'
+ YELLOW='\033[1;33m'
+ BLUE='\033[0;34m'
+ NC='\033[0m'
+ ACTION=auto
+ case "${1:-}" in
+ '[' auto = status ']'
+ '[' '!' -f build/c_relay_pg_static_x86_64 ']'
+ '[' '!' -f systemd/c-relay-pg-local.service ']'
+ info 'Checking PostgreSQL database '\''crelay_prod'\''...'
+ echo -e '\033[0;34m[INFO]\033[0m Checking PostgreSQL database '\''crelay_prod'\''...'
[INFO] Checking PostgreSQL database 'crelay_prod'...
+ PGPASSWORD=crelay
+ psql -U crelay -d crelay_prod -h 127.0.0.1 -c 'SELECT 1'
+ success 'Database '\''crelay_prod'\'' already exists'
+ echo -e '\033[0;32m[OK]\033[0m Database '\''crelay_prod'\'' already exists'
[OK] Database 'crelay_prod' already exists
+ info 'Ensuring deploy directory exists: /home/user/Storage/c_relay_pg'
+ echo -e '\033[0;34m[INFO]\033[0m Ensuring deploy directory exists: /home/user/Storage/c_relay_pg'
[INFO] Ensuring deploy directory exists: /home/user/Storage/c_relay_pg
+ mkdir -p /home/user/Storage/c_relay_pg
+ success 'Deploy directory ready: /home/user/Storage/c_relay_pg'
+ echo -e '\033[0;32m[OK]\033[0m Deploy directory ready: /home/user/Storage/c_relay_pg'
[OK] Deploy directory ready: /home/user/Storage/c_relay_pg
+ SERVICE_NEEDS_INSTALL=0
+ '[' auto = install ']'
+ '[' '!' -f /etc/systemd/system/c-relay-pg-local.service ']'
+ diff -q systemd/c-relay-pg-local.service /etc/systemd/system/c-relay-pg-local.service
+ '[' 0 -eq 1 ']'
+ info 'Stopping c-relay-pg-local (if running)...'
+ echo -e '\033[0;34m[INFO]\033[0m Stopping c-relay-pg-local (if running)...'
[INFO] Stopping c-relay-pg-local (if running)...
+ sudo systemctl stop c-relay-pg-local
++ lsof -ti :7777
++ true
+ PORT_PID=
+ '[' -n '' ']'
++ pgrep -f /home/user/Storage/c_relay_pg/caching_relay
++ true
+ CACHING_PIDS=
+ '[' -n '' ']'
+ info 'Installing relay binary: build/c_relay_pg_static_x86_64 -> /home/user/Storage/c_relay_pg/crelay'
+ echo -e '\033[0;34m[INFO]\033[0m Installing relay binary: build/c_relay_pg_static_x86_64 -> /home/user/Storage/c_relay_pg/crelay'
[INFO] Installing relay binary: build/c_relay_pg_static_x86_64 -> /home/user/Storage/c_relay_pg/crelay
+ cp build/c_relay_pg_static_x86_64 /home/user/Storage/c_relay_pg/crelay
+ chmod +x /home/user/Storage/c_relay_pg/crelay
+ success 'Relay binary installed'
+ echo -e '\033[0;32m[OK]\033[0m Relay binary installed'
[OK] Relay binary installed
+ '[' -f build/caching_relay ']'
+ info 'Installing caching binary: build/caching_relay -> /home/user/Storage/c_relay_pg/caching_relay'
+ echo -e '\033[0;34m[INFO]\033[0m Installing caching binary: build/caching_relay -> /home/user/Storage/c_relay_pg/caching_relay'
[INFO] Installing caching binary: build/caching_relay -> /home/user/Storage/c_relay_pg/caching_relay
+ cp build/caching_relay /home/user/Storage/c_relay_pg/caching_relay
+ chmod +x /home/user/Storage/c_relay_pg/caching_relay
+ success 'Caching binary installed (not auto-started; enable via config when ready)'
+ echo -e '\033[0;32m[OK]\033[0m Caching binary installed (not auto-started; enable via config when ready)'
[OK] Caching binary installed (not auto-started; enable via config when ready)
+ info 'Syncing admin dashboard to admin_prod/...'
+ echo -e '\033[0;34m[INFO]\033[0m Syncing admin dashboard to admin_prod/...'
[INFO] Syncing admin dashboard to admin_prod/...
+ rsync -a --delete --exclude=lib/config.php --exclude=php_server.log --exclude=cache/ admin/ admin_prod/
+ cp admin_prod/lib/config.php admin_prod/lib/config.php.prod
+ cp admin/lib/config.php admin_prod/lib/config.php
+ '[' -f admin_prod/lib/config.php.prod ']'
+ cp admin_prod/lib/config.php.prod admin_prod/lib/config.php
+ rm admin_prod/lib/config.php.prod
+ success 'Admin dashboard synced'
+ echo -e '\033[0;32m[OK]\033[0m Admin dashboard synced'
[OK] Admin dashboard synced
+ info 'Restarting production admin PHP server on port 7077...'
+ echo -e '\033[0;34m[INFO]\033[0m Restarting production admin PHP server on port 7077...'
[INFO] Restarting production admin PHP server on port 7077...
+ pkill -f 'php -S 127.0.0.1:7077'
+ sleep 1
+ disown 153527
+ setsid php -S 127.0.0.1:7077 -t admin_prod
+ sleep 1
+ success 'Production admin PHP server restarted on http://127.0.0.1:7077'
+ echo -e '\033[0;32m[OK]\033[0m Production admin PHP server restarted on http://127.0.0.1:7077'
[OK] Production admin PHP server restarted on http://127.0.0.1:7077
+ info 'Enabling and starting c-relay-pg-local...'
+ echo -e '\033[0;34m[INFO]\033[0m Enabling and starting c-relay-pg-local...'
[INFO] Enabling and starting c-relay-pg-local...
+ sudo systemctl enable c-relay-pg-local
+ sudo systemctl restart c-relay-pg-local
+ sleep 3
+ info 'Service status:'
+ echo -e '\033[0;34m[INFO]\033[0m Service status:'
[INFO] Service status:
+ sudo systemctl status c-relay-pg-local --no-pager -l
● c-relay-pg-local.service - C Nostr Relay Server (PostgreSQL Backend) - Local Production on port 7777
Loaded: loaded (/etc/systemd/system/c-relay-pg-local.service; enabled; preset: enabled)
Active: active (running) since Wed 2026-08-05 19:15:16 EDT; 3s ago
Invocation: c8cbad3b294a4566a00fa08b1f0c819a
Docs: https://github.com/your-repo/c-relay-pg
Main PID: 153634 (lws-main)
Tasks: 9 (limit: 7680)
Memory: 4.2M (peak: 5.2M)
CPU: 480ms
CGroup: /system.slice/c-relay-pg-local.service
└─153634 /home/user/Storage/c_relay_pg/crelay --debug-level=0 -p 7777 --strict-port --db-host 127.0.0.1 --db-name crelay_prod --db-user crelay --db-password crelay
Aug 05 19:15:16 ai c-relay-pg-local[153634]: NOTICE: column "backfill_authors_complete" of relation "caching_service_state" already exists, skipping
Aug 05 19:15:16 ai c-relay-pg-local[153634]: NOTICE: column "backfill_authors_total" of relation "caching_service_state" already exists, skipping
Aug 05 19:15:16 ai c-relay-pg-local[153634]: NOTICE: relation "caching_relays" already exists, skipping
Aug 05 19:15:16 ai c-relay-pg-local[153634]: NOTICE: relation "profiles" already exists, skipping
Aug 05 19:15:16 ai c-relay-pg-local[153634]: NOTICE: relation "idx_profiles_name" already exists, skipping
Aug 05 19:15:16 ai c-relay-pg-local[153634]: NOTICE: relation "idx_profiles_display_name" already exists, skipping
Aug 05 19:15:16 ai c-relay-pg-local[153634]: NOTICE: relation "idx_profiles_nip05" already exists, skipping
Aug 05 19:15:16 ai c-relay-pg-local[153634]: NOTICE: relation "ip_bans" already exists, skipping
Aug 05 19:15:16 ai c-relay-pg-local[153634]: [2026/08/05 19:15:16:3424] E: rops_pt_init_destroy_netlink: unable to open netlink
Aug 05 19:15:16 ai c-relay-pg-local[153634]: [2026-08-05 19:15:16] [WARN ] IP BAN SUMMARY: 0 auth-banned, 0 idle-banned, 1 tracked, 0 trusted (ever authed)
+ info 'Health check on port 7777...'
+ echo -e '\033[0;34m[INFO]\033[0m Health check on port 7777...'
[INFO] Health check on port 7777...
++ curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:7777
+ HEALTH_CODE=406
+ '[' 406 = 200 ']'
+ warn 'Relay returned HTTP 406 on port 7777 (may still be starting up)'
+ echo -e '\033[1;33m[WARN]\033[0m Relay returned HTTP 406 on port 7777 (may still be starting up)'
[WARN] Relay returned HTTP 406 on port 7777 (may still be starting up)
+ echo ' Check logs with: sudo journalctl -u c-relay-pg-local -f'
Check logs with: sudo journalctl -u c-relay-pg-local -f
+ info 'Verifying database connection...'
+ echo -e '\033[0;34m[INFO]\033[0m Verifying database connection...'
[INFO] Verifying database connection...
+ PGPASSWORD=crelay
+ psql -U crelay -d crelay_prod -h 127.0.0.1 -c 'SELECT current_user, current_database();'
+ success 'Database connection OK: crelay@crelay_prod'
+ echo -e '\033[0;32m[OK]\033[0m Database connection OK: crelay@crelay_prod'
[OK] Database connection OK: crelay@crelay_prod
+ echo ''
+ echo ==========================================
==========================================
+ success 'Local production relay deployed'
+ echo -e '\033[0;32m[OK]\033[0m Local production relay deployed'
[OK] Local production relay deployed
+ echo ==========================================
==========================================
+ echo 'WebSocket endpoint: ws://127.0.0.1:7777'
WebSocket endpoint: ws://127.0.0.1:7777
+ echo 'HTTP endpoint: http://127.0.0.1:7777'
HTTP endpoint: http://127.0.0.1:7777
+ echo 'Admin dashboard: http://127.0.0.1:7077'
Admin dashboard: http://127.0.0.1:7077
+ echo 'Database: crelay_prod (isolated from test relay'\''s '\''crelay'\'' db)'
Database: crelay_prod (isolated from test relay's 'crelay' db)
+ echo 'Service: c-relay-pg-local'
Service: c-relay-pg-local
+ echo 'Deploy dir: /home/user/Storage/c_relay_pg'
Deploy dir: /home/user/Storage/c_relay_pg
+ echo ''
+ echo 'Logs: sudo journalctl -u c-relay-pg-local -f'
Logs: sudo journalctl -u c-relay-pg-local -f
+ echo 'Status: ./deploy_local.sh --status'
Status: ./deploy_local.sh --status
+ echo ''
+ warn 'IMPORTANT: On first startup, the admin private key is printed ONCE in the logs.'
+ echo -e '\033[1;33m[WARN]\033[0m IMPORTANT: On first startup, the admin private key is printed ONCE in the logs.'
[WARN] IMPORTANT: On first startup, the admin private key is printed ONCE in the logs.
+ echo ' Retrieve it with:'
Retrieve it with:
+ echo ' sudo journalctl -u c-relay-pg-local --since="5 min ago" | grep -i "admin.*key"'
sudo journalctl -u c-relay-pg-local --since="5 min ago" | grep -i "admin.*key"
+ echo ''
+ echo 'Test relay (port 8888) is unaffected — run it separately with ./make_and_restart_relay.sh'
Test relay (port 8888) is unaffected — run it separately with ./make_and_restart_relay.sh
+ echo 'Test admin UI: http://127.0.0.1:8088'
Test admin UI: http://127.0.0.1:8088