我有默认的GAE服务,虽然我想实现微服务。默认版本有两个版本,我只在其中一个版本中实现微服务,因为我需要在将它放入主版本之前对其进行测试。对于这个新的微服务,我创建了文件my_module.py和my_module.yaml。当我运行代码“ appcfg.py update my_module.py ”时,上传/更新完全正常,如下面的日志所示:
10:28 AM Host: appengine.google.com
10:28 AM Application: application_name; module: my_module; version: one
10:28 AM Starting update of app: application_name, module: my_module, version: one
10:28 AM Getting current resource limits.
10:28 AM Scanning files on local disk.
10:28 AM Cloning 2 application files.
10:28 AM Compilation starting.
10:28 AM Compilation completed.
10:28 AM Starting deployment.
10:28 AM Checking if deployment succeeded.
10:28 AM Deployment successful.
10:28 AM Checking if updated app version is serving.
10:28 AM Completed update of app: application_name, module: my_module, version: one
但是,当我去console.cloud.google.com查看日志时,我经常会看到错误:
Traceback (most recent call last):
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
ImportError: No module named my_module
拜托,有人知道为什么会这样吗?
更新:我正在使用新微服务的代码。
my_module.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
import webapp2
class MainHandler(webapp2.RedirectHandler):
def get(self):
self.response.out.write('Hello!')
return
app = webapp2.WSGIApplication([
('/', MainHandler)
], debug=True)
my_module.yaml
application: application_name
module: my_module
version: one
runtime: python27
api_version: 1
threadsafe: true
instance_class: B1
basic_scaling:
max_instances: 1
idle_timeout: 13s
skip_files:
- ^(./)?app.yaml
- ^(./)?app.yml
- ^(./)?index.yaml
- ^(./)?index.yml
- ^(./)?#.#
- ^(./)?.~
- ^(./)?..py[co]
- ^(./)?./RCS/.*
- ^(./)?..
- ^(./)?tests$
- ^(./)?node_modules/.*
- ^(./)?Gruntfile.js
- ^(./)?package.json
handlers:
- url: /.*
script: my_module.app
更新:解决方案
正如Avinash Raj在评论中建议的那样,我刚刚从my_module.yaml中删除了 - ^(。/)?.. ,它开始起作用。
答案 0 :(得分:1)
我建议您从^(./)?..
部分删除skip_files
regex stmt,因为正则表达式中未转义的点不仅匹配一个点,而且它匹配任何单个字符,导致跳过任何至少有文件的文件两个字母在他们的名字。如果你真的是指一个点,那就像^(./)?\.\.