I have a local NodeJS application that I am building locally.
I want the local application to point to the local Datastore Emulator (not the production Cloud Datastore).
I followed the instructions on this page... However, the application is still pointing to the CLOUD datastore (not my local datastore). I confirmed this because data is showing up in the Datastore Entities page on App Engine.
According to this page, https://cloud.google.com/datastore/docs/tools/datastore-emulator all that should be required is to set environment variables by running this command:
$(gcloud beta emulators datastore env-init)
I confirmed the environment variables are being set correctly. Why is my application still pointing to the Cloud Datastore and not the local emulator?
myusername$ $(gcloud beta emulators datastore env-init)
myusername$ gcloud beta emulators datastore env-init
export DATASTORE_DATASET=projectname
export DATASTORE_EMULATOR_HOST=localhost:8081
export DATASTORE_EMULATOR_HOST_PATH=localhost:8081/datastore
export DATASTORE_HOST=http://localhost:8081
export DATASTORE_PROJECT_ID=projectname
Here is the output when running the emulator:
myname$ gcloud beta emulators datastore start
WARNING: Reusing existing data in [/Users/myname/.config/gcloud/emulators/datastore].
Executing: /Users/myname/google-cloud-sdk/platform/cloud-datastore-emulator/cloud_datastore_emulator start --host=localhost --port=8081 --store_on_disk=True --consistency=0.9 --allow_remote_shutdown /Users/myname/.config/gcloud/emulators/datastore
[datastore] Oct 30, 2017 3:47:46 PM com.google.cloud.datastore.emulator.CloudDatastore$FakeDatastoreAction$8 apply
[datastore] INFO: Provided --allow_remote_shutdown to start command which is no longer necessary.
[datastore] Oct 30, 2017 3:47:46 PM com.google.cloud.datastore.emulator.impl.LocalDatastoreFileStub <init>
[datastore] INFO: Local Datastore initialized:
[datastore] Type: High Replication
[datastore] Storage: /Users/myname/.config/gcloud/emulators/datastore/WEB-INF/appengine-generated/local_db.bin
[datastore] Oct 30, 2017 3:47:47 PM com.google.cloud.datastore.emulator.impl.LocalDatastoreFileStub load
[datastore] INFO: The backing store, /Users/myname/.config/gcloud/emulators/datastore/WEB-INF/appengine-generated/local_db.bin, does not exist. It will be created.
[datastore] Oct 30, 2017 3:47:47 PM io.gapi.emulators.netty.NettyUtil applyJava7LongHostnameWorkaround
[datastore] INFO: Unable to apply Java 7 long hostname workaround.
[datastore] API endpoint: http://localhost:8081
[datastore] If you are using a library that supports the DATASTORE_EMULATOR_HOST environment variable, run:
[datastore]
[datastore] export DATASTORE_EMULATOR_HOST=localhost:8081
[datastore]
[datastore] Dev App Server is now running.
[datastore]