在docs之后,我从CMD Shell启动了GAE Datastore Emulator。
我用过:
gcloud beta emulators datastore start --data-dir=j:\projects\project\datastore
输出为:
WARNING: Reusing existing data in [j:\projects\project\datastore].
Executing: cmd /c C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\cloud-datastore-emulator\cloud_datastore_emulator.cmd start --host=localhost --port=8081 --store_on_disk=True --consistency=0.9 --allow_remote_shutdown j:\projects\project\datastore
[datastore] Jun 08, 2019 5:24:52 PM com.google.cloud.datastore.emulator.CloudDatastore$FakeDatastoreAction$9 apply
[datastore] INFO: Provided --allow_remote_shutdown to start command which is no longer necessary.
[datastore] Jun 08, 2019 5:24:52 PM com.google.cloud.datastore.emulator.impl.LocalDatastoreFileStub <init>
[datastore] INFO: Local Datastore initialized:
[datastore] Type: High Replication
[datastore] Storage: j:\projects\jupiter\datastore\WEB-INF\appengine-generated\local_db.bin
[datastore] Jun 08, 2019 5:24:53 PM com.google.cloud.datastore.emulator.impl.LocalDatastoreFileStub load
[datastore] INFO: The backing store, j:\projects\project\datastore\WEB-INF\appengine-generated\local_db.bin, does not exist. It will be created.
[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]
[datastore] The previous line was printed for backwards compatibility only.
[datastore] If your tests rely on it to confirm emulator startup,
[datastore] please migrate to the emulator health check endpoint (/). Thank you!
浏览到localhost:8081
会返回Ok
在第二个CMD shell中,我尝试:
gcloud beta emulators datastore env-init --data-dir=j:\projects\project\datastore > set_vars.cmd && set_vars.cmd
(Google文档没有提及--data-dir=j:\projects\project\datastore
,但如果没有它,该工具的位置将显示在错误的位置)
但是它失败了:
ERROR: (gcloud.beta.emulators.datastore.env-init) Unable to find env.yaml in the data_dir
[C:\Users\c\AppData\Roaming\gcloud\emulators\datastore]. Please ensure you have started the appropriate emulator.
如果我手动设置环境变量,我将从CMD shell中获得相同的结果。
答案 0 :(得分:1)
我试图重现您的用例场景,并且对我有用。这就是我遵循的:
"text"
$ gcloud components install cloud-datastore-emulator
$ gcloud beta emulators datastore start --data-dir=C:\PATH\TO\datastore
You do not currently have this command group installed. Using it requires the installation of components: [beta]
$ gcloud components install beta
$ gcloud beta emulators datastore start --data-dir=C:\PATH\TO\datastore
$ gcloud beta emulators datastore env-init --data-dir=C:\PATH\TO\datastore > set_vars.cmd && set_vars.cmd
我建议从其他目录再次尝试该过程。确保:
答案 1 :(得分:0)
更新后于2019-09-07发表评论。
如果您坚持使用Google App Engine(GAE)标准Python 2.7,并且必须运行本地版本的GDS,这是我的处理方式(虽然不能直接回答问题,但仍可能与)。 我使用数据存储区参数运行dev_appengine。在Windows上,.bat文件可能如下所示:
set PY="c:\/python27\/python.exe"
set GAE="C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\dev_appserver.py"
set GCSEMU="C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\cloud-datastore-emulator\cloud_datastore_emulator.cmd"
%PY% %GAE% --skip_sdk_update_check=True --datastore_emulator_cmd=%GCSEMU% --port 8080 --host oe.loc .
也有商店位置的参数。