Updates
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Mint a pa1 invite from SERVER_SEED without starting the full server process.
|
||||
* Mint a pd1 invite from SERVER_SEED without starting the full server process.
|
||||
*
|
||||
* Usage:
|
||||
* node scripts/mint-invite.js [role=operator] [ttlMs]
|
||||
|
||||
+30
-16
@@ -27,7 +27,6 @@ fi
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
cd "$ROOT"
|
||||
|
||||
# Derive invite prefix from first letters + 1.
|
||||
PREFIX="$(echo "$NEW_SLUG" | tr -cd 'a-z' | cut -c1-2)1."
|
||||
ENV_PREFIX="$(echo "$NEW_SLUG" | tr 'a-z-' 'A-Z_')_"
|
||||
ENV_PREFIX="${ENV_PREFIX//__/_}"
|
||||
@@ -40,24 +39,39 @@ echo " invite: $OLD_PREFIX → $PREFIX"
|
||||
echo " env: $OLD_ENV → $ENV_PREFIX"
|
||||
|
||||
export LC_ALL=C
|
||||
find . -type f \
|
||||
\( -name '*.js' -o -name '*.mjs' -o -name '*.cjs' -o -name '*.json' -o -name '*.md' -o -name '*.html' -o -name '*.css' -o -name '*.yml' -o -name '*.yaml' -o -name '*.service' -o -name '*.example' -o -name '*.sh' \) \
|
||||
! -path './node_modules/*' ! -path './.git/*' ! -path './data/*' \
|
||||
-print0 | while IFS= read -r -d '' f; do
|
||||
perl -pi -e "
|
||||
s/\Q$OLD_NAME\E/$NEW_SLUG/g;
|
||||
s/\Q$OLD_PRODUCT\E/$NEW_PRODUCT/g;
|
||||
s/\Q$OLD_PROTOCOL\E/${NEW_SLUG}\\/rpc/g;
|
||||
s/\Q$OLD_SLUG\E/$NEW_SLUG/g;
|
||||
s/\Q$OLD_PREFIX\E/$PREFIX/g;
|
||||
s/\Q$OLD_ENV\E/$ENV_PREFIX/g;
|
||||
" "$f"
|
||||
done
|
||||
# Use python for safe replacements (perl struggles with slashes in protocol id)
|
||||
python3 - "$OLD_NAME" "$NEW_SLUG" "$OLD_PRODUCT" "$NEW_PRODUCT" "$OLD_PROTOCOL" "${NEW_SLUG}/rpc" "$OLD_SLUG" "$NEW_SLUG" "$OLD_PREFIX" "$PREFIX" "$OLD_ENV" "$ENV_PREFIX" <<'PY'
|
||||
import os, sys
|
||||
from pathlib import Path
|
||||
|
||||
if [[ -f bin/peardata-server.mjs ]]; then
|
||||
pairs = list(zip(sys.argv[1::2], sys.argv[2::2]))
|
||||
# longer keys first
|
||||
pairs.sort(key=lambda x: -len(x[0]))
|
||||
SKIP = {'node_modules', '.git', 'data'}
|
||||
EXTS = {'.js','.mjs','.cjs','.json','.md','.html','.css','.yml','.yaml','.service','.example','.sh'}
|
||||
|
||||
for dirpath, dirnames, filenames in os.walk('.'):
|
||||
dirnames[:] = [d for d in dirnames if d not in SKIP]
|
||||
for name in filenames:
|
||||
p = Path(dirpath) / name
|
||||
if p.suffix not in EXTS:
|
||||
continue
|
||||
try:
|
||||
text = p.read_text(encoding='utf-8')
|
||||
except Exception:
|
||||
continue
|
||||
orig = text
|
||||
for a, b in pairs:
|
||||
text = text.replace(a, b)
|
||||
if text != orig:
|
||||
p.write_text(text, encoding='utf-8')
|
||||
print('updated', p)
|
||||
PY
|
||||
|
||||
if [[ -f bin/peardata-server.mjs && "$NEW_SLUG" != "peardata" ]]; then
|
||||
mv bin/peardata-server.mjs "bin/${NEW_SLUG}-server.mjs"
|
||||
fi
|
||||
if [[ -f deploy/peardata.service ]]; then
|
||||
if [[ -f deploy/peardata.service && "$NEW_SLUG" != "peardata" ]]; then
|
||||
mv deploy/peardata.service "deploy/${NEW_SLUG}.service"
|
||||
fi
|
||||
|
||||
|
||||
+7
-4
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Soak test: connect, post messages, verify pushes for SOAK_DURATION_MS.
|
||||
* Soak test: connect, query metrics, ping for SOAK_DURATION_MS.
|
||||
*
|
||||
* Usage:
|
||||
* SERVER_PUBLIC_KEY=… SERVER_SEED=… node scripts/soak.js
|
||||
@@ -26,18 +26,21 @@ let received = 0
|
||||
let sent = 0
|
||||
let errors = 0
|
||||
|
||||
conn.on(Pushes.message, () => {
|
||||
conn.on(Pushes.metrics, () => {
|
||||
received++
|
||||
})
|
||||
|
||||
await conn.connect()
|
||||
console.log('soak connected as', conn.role)
|
||||
await conn.request(Methods.subscribeMetrics, { charts: ['*'], intervalMs: 1000 })
|
||||
|
||||
const end = Date.now() + duration
|
||||
while (Date.now() < end) {
|
||||
try {
|
||||
await conn.request(Methods.postMessage, {
|
||||
text: `soak ${sent} @ ${new Date().toISOString()}`,
|
||||
await conn.request(Methods.queryData, {
|
||||
chart: 'system.cpu',
|
||||
after: -30,
|
||||
points: 30,
|
||||
})
|
||||
sent++
|
||||
await conn.ping()
|
||||
|
||||
Reference in New Issue
Block a user