gpt4 book ai didi

google-app-engine - 如何调试 Dart AppEngine 应用程序

转载 作者:太空宇宙 更新时间:2023-11-03 15:21:09 26 4
gpt4 key购买 nike

我现在可以运行 Dart 应用程序了

gcloud --verbosity debug preview app run app.yaml

也可以在 AppEngine 上部署和运行

gcloud --verbosity debug preview app deploy app.yaml

但我还没有找到将调试器连接到在开发服务器上运行的 Dart 应用程序的方法。

我找到了 http://dartbug.com/21067但仍然找不到让它发挥作用的方法。

另见 https://groups.google.com/a/dartlang.org/forum/#!topic/cloud/OK1nJtg7AjQ

最佳答案

更新2015-02-27

该应用程序可以在没有 Docker 的情况下运行,然后像任何 Dart 命令行应用程序一样进行调试:来源。 https://groups.google.com/a/dartlang.org/d/msg/cloud/zrxgOHFz_lA/q5CdLLQPBAgJ

The API server is part of the App Engine SDK, and we are using it forrunning tests in the appengine package. If you look athttps://github.com/dart-lang/appengine/blob/master/tool/run_tests.shyou will see that it expects the environment variableAPPENGINE_API_SERVER.

The API server is in /platform/google_appengine/api_server.py

and takes a number of arguments. I just tested running it like this:

$ $CLOUD_SDK/platform/google_appengine/api_server.py \ -Adev~test-application \ --api_port 4444 \ --high_replication \
--datastore_path /tmp/datastore

To run an app engine application outside the normal development serverrequires that a number of environment variables are set. This workedfor my application:

$ GAE_LONG_APP_ID=test-application \ GAE_MODULE_NAME=default \
GAE_MODULE_VERSION=version \ GAE_PARTITION=dev \ API_PORT=4444 \
API_HOST=127.0.0.1 \ dart bin/server.dart

In the Dart Editor you cannot set environment variables for eachlaunch configuration, so they have to be set globally before startingthe Dart Editor. In WebStorm it is possible to have run configurationspecific environment variables.

This simple setup will of cause not support everything the normaldevelopment server support. Some of the issues are:

  • Only one application at the time as it is always listening on port8080 (can easily be made configurable) * The users API (mocking thisshouldn't be that difficult) * The modules API * No health-checks(should not be a problem) * All HTTP headers are direct from theclient (no x-appengine- headers) * The admin web interface is notavailable * Probably other stuff as well

This is all experimental, but it is one solution for a simplerdeveloper setup, which of cause does not match the deploymentenvironment as closely as the development server.

Running the API Server using Docker is also possible as the imagegoogle/cloud-sdk with the Cloud SDK is on hub.docker.com.

Use the following Dockerfile

FROM google/cloud-sdk EXPOSE 4444 ENTRYPOINT["/google-cloud-sdk/platform/google_appengine/api_server.py", \
"-A", "dev~test-application", \ "--api_port", "4444", \
"--high_replication", \ "--datastore_path", "/tmp/datastore"]

Build and run

$ docker build -t api_server . $ docker run -d -p 4444:4444 api_server

Change API_HOST above to 192.166.59.103 (of wherever your Dockercontainers are) and run.

Regards, Søren Gjesse

更新2014-11-27

从 DartEditors 调试器调试开始使用流血的 Dart 构建 1.8.0.edge_042017 .我假设下一个开发版本(可能是 1.9.0-dev1.0)也将包括相关修复?

可在此处找到其工作原理的详细步骤:https://groups.google.com/a/dartlang.org/d/msg/cloud/OK1nJtg7AjQ/u-GzUDI-0VIJ

env_variables:
DBG_ENABLE: 'true'

# disable health-checking because this is so annoying during debugging
vm_health_check:
enable_health_check: False

参见 How to disable health checking for `gcloud preview app run`有关自定义健康检查的更多详细信息。

  • 使用 glcoud --verbosity debug app run app.yaml 启动您应用程序的服务器代码或 glcoud --verbosity debug app run app.yaml index.yaml

  • 等待 Docker 容器准备就绪(检查 docker ps 是否 Command 列显示以 /dart_runtime/dart_ 开头的值

  • 打开 DartEditor

  • 打开菜单 Run > Remote Connection...

    • 连接到:Command-line VM

    • 主持人:localhost如果你不t use boot2docker or the IP address returned by the command boot2docker ip`

    • 端口:5005

    • Select Folder...选择包含项目源代码的目录。

    • 点击OK

    • 设置断点并照常继续。

第一步是使用 Observatory其中包括一个基于浏览器的调试器 UI。

要完成这项工作,请将以下行添加到 app.yaml文件

network:
forwarded_ports: ["8181"]

这对于制作 server.dart 可能也很有用。等到我们有机会使用天文台设置断点。

env_variables:
DART_VM_OPTIONS: '--pause-isolates-on-start'

boot2docker给我们 Docker ip (192.168.59.103) 并在以 gcloud preview app run app.yaml 开始后我们可以连接到http://192.168.59.103:8181这应该会打开 Observatory GUI。

关于google-app-engine - 如何调试 Dart AppEngine 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26807828/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com