blob: ca6ac3628997930f30847902a5b749eb22812f16 [file] [log] [blame]
#!/bin/bash
function kill_emulators()
{
kill -9 `ps aux | grep "[g]cloud\.py" | awk '{print $2}'`
kill -9 `ps aux | grep "[c]loud_datastore_emulator" | awk '{print $2}'`
kill -9 `ps aux | grep "[C]loudDatastore.jar" | awk '{print $2}'`
kill -9 `ps aux | grep "[c]btemulator" | awk '{print $2}'`
}
# Starts and stops the cloud datastore emulator.
case "$1" in
"start")
# make sure it's not running then start the emulator.
kill_emulators
set -e
gcloud beta emulators datastore start \
--no-store-on-disk \
--host-port=localhost:8891 \
--project=test-project > /tmp/datastore_emulator.log 2>&1 &
gcloud beta emulators bigtable start \
--host-port=localhost:8892 \
--project=test-project > /tmp/bigtable_emulator.log 2>&1 &
gcloud beta emulators pubsub start \
--host-port=localhost:8893 \
--project=test-project > /tmp/pubsub_emulator.log 2>&1 &
set -e
sleep 5s
cat /tmp/datastore_emulator.log
cat /tmp/bigtable_emulator.log
cat /tmp/pubsub_emulator.log
echo "Cloud datastore,Bigtable and PubSub emulators started."
;;
"stop")
kill_emulators
echo "Cloud datastore and Bigtable emulators stopped."
;;
*)
echo "Error: argument must be {start|stop}"
exit 1
;;
esac