Files
firefox-accounts-mirror/_scripts/sync-populate.sh
dschom a3ae0fe74a task(all): Get new syncstorage-rs service running
Because:
- Locally the sync service wasn't running.
- We couldn't test sync flows against a local sync server
- There's a new version of the sync server that uses rust

This Commit:
- Sets up a dockerfile for syncstorage-rs that is tailored to fxa's local stack
- Updates pm2 sync job to run this docker container and initialize its databases.
- Updates firefox config/profile to point at this service
- Starts firefox up with the FIREFOX_DEBUGGER=true env.
  - Useful for debugging sync
  - Useful for debugging FxA web channel messages
2024-08-27 09:57:20 -07:00

37 lines
1.5 KiB
Bash
Executable File

#!/bin/bash -e
# This will populate sync's tokenserver db with minimal state to ensure the token server is
# functional. Note, that sync will start and autmatically setup the database schemas. Once
# this happens, we can then run these inserts to setup the initial database state required
# for run sync to serve requrest from firefox.
_scripts/check-url.sh localhost:8000/__heartbeat__
RETRY=240
echo "waiting on tokenserver db to be created."
for i in $(eval echo "{1..$RETRY}"); do
db=$(docker exec mydb mysql --silent --skip-column-names -e 'SELECT SCHEMA_NAME FROM information_schema.SCHEMATA WHERE SCHEMA_NAME = "tokenserver";')
if [ -z "$db" ]; then
echo -e -n "\r ...no response, retry attempt $i of $RETRY"
sleep 1
else
echo ""
echo "sync db exists! populating..."
docker exec mydb mysql -e 'INSERT INTO tokenserver.services (service, pattern) VALUES ("sync-1.5", "{node}/1.5/{uid}")'
docker exec mydb mysql -e 'INSERT INTO tokenserver.nodes (service, node, available, capacity, current_load, backoff, downed, id) VALUES ((select id from tokenserver.services limit 1), "http://localhost:8000", 100, 100, 0, 0, 0, 800)'
echo "done populating sync database state!"
echo "token.nodes:"
docker exec mydb mysql -e 'select * from tokenserver.nodes;'
echo "tokenserver.services:"
docker exec mydb mysql -e 'select * from tokenserver.services;'
exit 0
fi
done
echo "tokenserver database was never created.... giving up!"