Files
keyhunter-parser/lane_shard.sh

22 lines
778 B
Bash
Executable File

#!/bin/bash
# sharded lane keeper: this box runs lanes where crc32(name) % SHARDS == SHARD
cd /root/keyhunter || exit 1
mkdir -p data
SHARD=${KH_NODE_SHARD:-0}
SHARDS=${KH_NODE_SHARDS:-4}
LANES=$(python3 -c "
import glob, zlib, sys
shard, shards = int(sys.argv[1]), int(sys.argv[2])
lanes = sorted(p for p in glob.glob('*_eternal.py')
if zlib.crc32(p[:-3].encode()) % shards == shard)
# baipiao and gh_realtime forced on all shards; dedup against LANES
forced = []
for extra in ('baipiao_eternal.py', 'gh_realtime_eternal.py'):
if extra not in lanes:
forced.append(extra)
print(' '.join(lanes + forced))
" "$SHARD" "$SHARDS")
for f in $LANES; do
pgrep -f "python3 $f" >/dev/null || setsid nohup python3 "$f" >>"data/scan_${f%.py}.log" 2>&1 </dev/null &
done