1

配置端點API時遇到問題。我使用,從我自己的,谷歌的例子在現場的任何代碼失敗,相同的回溯Google App Engine配置端點API

WARNING 2016-11-01 06:16:48,279 client.py:229] no scheduler thread, scheduler.run() will be invoked by report(...) 
Traceback (most recent call last): 
File "/home/vladimir/projects/sb_fork/sb/lib/vendor/google/api/control/client.py", line 225, in start 
self._thread.start() 
File "/home/vladimir/sdk/google-cloud-sdk/platform/google_appengine/google/appengine/api/background_thread/background_thread.py", line 108, in start 
start_new_background_thread(self.__bootstrap,()) 
File "/home/vladimir/sdk/google-cloud-sdk/platform/google_appengine/google/appengine/api/background_thread/background_thread.py", line 87, in start_new_background_thread 
raise ERROR_MAP[error.application_error](error.error_detail) 
FrontendsNotSupported 
INFO  2016-11-01 06:16:48,280 client.py:327] created a scheduler to control flushing 
INFO  2016-11-01 06:16:48,280 client.py:330] scheduling initial check and flush 
INFO  2016-11-01 06:16:48,288 client.py:804] Refreshing access_token 
/home/vladimir/projects/sb_fork/sb/lib/vendor/urllib3/contrib/appengine.py:113: AppEnginePlatformWarning: urllib3 is using URLFetch on Google App Engine sandbox instead of sockets. To use sockets directly instead of URLFetch see https://urllib3.readthedocs.io/en/latest/contrib.html. 
AppEnginePlatformWarning) 
ERROR 2016-11-01 06:16:49,895 service_config.py:125] Fetching service config failed (status code 403) 
ERROR 2016-11-01 06:16:49,896 wsgi.py:263] 
Traceback (most recent call last): 
File "/home/vladimir/sdk/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle 
handler = _config_handle.add_wsgi_middleware(self._LoadHandler()) 
File "/home/vladimir/sdk/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler 
handler, path, err = LoadObject(self._handler) 
File "/home/vladimir/sdk/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject 
obj = __import__(path[0]) 
File "/home/vladimir/projects/sb_fork/sb/main.py", line 27, in <module> 
api_app = endpoints.api_server([SolarisAPI,], restricted=False) 
File "/home/vladimir/projects/sb_fork/sb/lib/vendor/endpoints/apiserving.py", line 497, in api_server 
controller) 
File "/home/vladimir/projects/sb_fork/sb/lib/vendor/google/api/control/wsgi.py", line 77, in add_all 
a_service = loader.load() 
File "/home/vladimir/projects/sb_fork/sb/lib/vendor/google/api/control/service.py", line 110, in load 
return self._load_func(**kw) 
File "/home/vladimir/projects/sb_fork/sb/lib/vendor/google/api/config/service_config.py", line 78, in fetch_service_config 
_log_and_raise(Exception, message_template.format(status_code)) 
File "/home/vladimir/projects/sb_fork/sb/lib/vendor/google/api/config/service_config.py", line 126, in _log_and_raise 
raise exception_class(message) 
Exception: Fetching service config failed (status code 403) 
INFO  2016-11-01 06:16:49,913 module.py:788] default: "GET/HTTP/1.1" 500 - 

app.yaml配置像新端點遷移到2.0文件規定:

- url: /_ah/api/.* 
    script: api.solaris.api_app 

而且main.py進口該API到應用程序:

api_app = endpoints.api_server([SolarisAPI,], restricted=False) 

我使用谷歌雲SDK與這些版本:

Google Cloud SDK 132.0.0 
app-engine-python 1.9.40 
bq 2.0.24 
bq-nix 2.0.24 
core 2016.10.24 
core-nix 2016.10.24 
gcloud 
gsutil 4.22 
gsutil-nix 4.22 

回答

1

要擺脫「FrontendsNotSupported」,您需要使用「B *」實例類。

如果您按照https://cloud.google.com/endpoints/docs/frameworks/python/quickstart-frameworks-python中的步驟操作,則應該消除「異常:獲取服務配置失敗」錯誤。正如Brad已經指出的那樣,需要「OpenAPI配置」部分和生成的環境變量來使服務配置生效。

+1

我無法關注「您需要使用」B *「實例類。」 你可以提供更多的信息嗎? – user362953

+0

@ user362953您的appengine服務實例有一個類,它指定您的應用程序需要/使用的類或資源(CPU,內存)。 'https://cloud.google。com/appengine/docs/standard /#instance_classes' 你可以找到關於它的所有信息。 –

2

您是否嘗試過生成並上傳服務的OpenAPI配置?請參閱python library documentation中名爲"Generating the OpenAPI configuration file""Deploying the OpenAPI configuration file"的部分。

請注意,在生成過程的第2步中,您可能需要在命令前加上python(例如python lib/endpoints/endpointscfg.py get_swagger_spec ...),因爲PyPi包現在不保留可執行文件許可權。

+0

這是缺少的一步,我有像在這個問題的環境相同的問題,我似乎無法解決appengine.ext [issue](http://stackoverflow.com/questions/ 39926853/error-running-endpointscfg-py-get-swagger-spec) – dgmt

+0

@Brad 即使在app.yaml中有正確的'env_variables',我也會看到同樣的錯誤。 任何想法爲什麼可能是這種情況? http://stackoverflow.com/questions/42310672/google-appengine-endpoints-error-fetching-service-config-failed-status-code-40有更多信息。 – user362953

+0

我回答了這個問題,但是複製了我在這裏說的話 - gcloud服務管理部署步驟可能無法按預期工作。我會再試一次,確保所有內容都正確配置,並確保在該命令中沒有錯誤輸出。讓我知道如果這有效! :) –