在App Engine localhost上启动Go服务器会引发错误

时间:2017-07-08 17:23:39

标签: google-app-engine go

任何人都可以告诉我为什么会这样:

$ dev_appserver.py nmg_server
INFO     2017-07-08 17:15:37,369 application_configuration.py:461] No version specified. Generated version id: 20170708t171537
WARNING  2017-07-08 17:15:37,369 application_configuration.py:166] The Managed VMs runtime is deprecated, please consider migrating your application to use the Flexible runtime. See https://cloud.google.com/appengine/docs/flexible/python/migrating for more details.
INFO     2017-07-08 17:15:37,472 devappserver2.py:116] Skipping SDK update check.
INFO     2017-07-08 17:15:37,513 api_server.py:312] Starting API server at: http://localhost:54096
INFO     2017-07-08 17:15:37,517 api_server.py:938] Applying all pending transactions and saving the datastore
INFO     2017-07-08 17:15:37,517 api_server.py:941] Saving search indexes
Traceback (most recent call last):
  File "/Users/dgaedcke/gcloud_tools/google-cloud-sdk/platform/google_appengine/dev_appserver.py", line 103, in <module>
    _run_file(__file__, globals())
  File "/Users/dgaedcke/gcloud_tools/google-cloud-sdk/platform/google_appengine/dev_appserver.py", line 97, in _run_file
    execfile(_PATHS.script_file(script_name), globals_)
  File "/Users/dgaedcke/gcloud_tools/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 381, in <module>
    main()
  File "/Users/dgaedcke/gcloud_tools/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 369, in main
    dev_server.start(options)
  File "/Users/dgaedcke/gcloud_tools/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 196, in start
    options.api_host, apiserver.port, wsgi_request_info_, options.grpc_apis)
  File "/Users/dgaedcke/gcloud_tools/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/dispatcher.py", line 223, in start
    _module.start()
  File "/Users/dgaedcke/gcloud_tools/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/module.py", line 1647, in start
    self._add_instance()
  File "/Users/dgaedcke/gcloud_tools/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/module.py", line 1799, in _add_instance
    expect_ready_request=True)
  File "/Users/dgaedcke/gcloud_tools/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/go_runtime.py", line 189, in new_instance
    self._go_application.maybe_build()):
TypeError: maybe_build() takes exactly 2 arguments (1 given)

我试图运行我的服务器在localhost上进行测试,并且它一直在退出此错误

1 个答案:

答案 0 :(得分:1)

这似乎是Cloud SDK中的一个错误,与dev_appserver.py一起使用时会影响App Engine Managed VMs。它似乎不会影响App Engine Standard或App Engine Flex环境。

在Google发布带有该修补程序的新Cloud SDK之前,您可以在本地修改CLOUD_SDK_INSTALL_DIR//platform/google_appengine/google/appengine/tools/devappserver2/go_managedvm.py文件,如下所示(为方便起见,同时添加了可修补的统一差异以及之前/之后)。

同时考虑从Managed VMs are deprecated and will not be supported after October 27, 2017开始转移到App Engine Flex。

  

警告:托管虚拟机测试版环境(部署了应用程序的应用程序)   vm:true)已弃用,将退役。此页面适用于   已经使用vm:true的灵活环境的用户   他们的app.yaml并希望升级到最新版本。如果你是   从标准环境更新您的应用程序,请参阅   Migrating Services from the Standard Environment to the Flexible Environment instead

Diff in patchable format

--- /Users/tuxdude/google-cloud-sdk-orig/platform/google_appengine/google/appengine/tools/devappserver2go_managedvm.py     2017-07-08 11:11:11.000000000 -0700
+++ /Users/tuxdude/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/go_managedvm.py      2017-07-08 11:11:11.000000000 -0700
@@ -152,15 +152,9 @@
     logging.debug('Build succeeded:\n%s\n%s', stdout, stderr)
     self._go_executable = exe_name

-  def maybe_build(self, maybe_modified_since_last_build):
+  def maybe_build(self):
     """Builds an executable for the application if necessary.

-    Args:
-      maybe_modified_since_last_build: True if any files in the application root
-          or the GOPATH have changed since the last call to maybe_build, False
-          otherwise. This argument is used to decide whether a build is Required
-          or not.
-
     Returns:
       True if compilation was successfully performed (will raise
         an exception if compilation was attempted but failed).
@@ -173,9 +167,6 @@
       self._work_dir = tempfile.mkdtemp('appengine-go-bin')
       atexit.register(_rmtree, self._work_dir)

-    if self._go_executable and not maybe_modified_since_last_build:
-      return False
-
     if self._go_executable:
       logging.debug('Rebuilding Go application due to source modification')
     else:

之前:

  def maybe_build(self, maybe_modified_since_last_build):
    """Builds an executable for the application if necessary.

    Args:
      maybe_modified_since_last_build: True if any files in the application root
          or the GOPATH have changed since the last call to maybe_build, False
          otherwise. This argument is used to decide whether a build is Required
          or not.

    Returns:
      True if compilation was successfully performed (will raise
        an exception if compilation was attempted but failed).
      False if compilation was not attempted.

    Raises:
      BuildError: if building the executable fails for any reason.
    """
    if not self._work_dir:
      self._work_dir = tempfile.mkdtemp('appengine-go-bin')
      atexit.register(_rmtree, self._work_dir)

    if self._go_executable and not maybe_modified_since_last_build:
      return False

    if self._go_executable:
      logging.debug('Rebuilding Go application due to source modification')
    else:
      logging.debug('Building Go application')
    self._build()
    return True

后:

  def maybe_build(self):
    """Builds an executable for the application if necessary.

    Returns:
      True if compilation was successfully performed (will raise
        an exception if compilation was attempted but failed).
      False if compilation was not attempted.

    Raises:
      BuildError: if building the executable fails for any reason.
    """
    if not self._work_dir:
      self._work_dir = tempfile.mkdtemp('appengine-go-bin')
      atexit.register(_rmtree, self._work_dir)

    if self._go_executable:
      logging.debug('Rebuilding Go application due to source modification')
    else:
      logging.debug('Building Go application')
    self._build()
    return True