App Engine实例不是从基本缩放开始,而是使用自动缩放

时间:2016-06-24 03:53:01

标签: django google-app-engine

我正在尝试使用基本扩展在App Engine上启动项目,但它无法启动。该应用程序适用于自动缩放。当应用处于自动缩放时,/_ah/start会返回200。我无法弄清楚为什么应用程序只会在设置自动缩放时启动。

这是app.yaml,这是一个非常标准的应用:

application: myapp
module: default
version: 1-1
runtime: python27
api_version: 1
threadsafe: yes

libraries:
- name: lxml
  version: "2.3"

handlers:
- url: /static
  static_dir: static

- url: /favicon\.ico
  static_files: static/img/favicon.ico
  upload: static/img/favicon.ico

- url: /_ah/(mapreduce|queue|warmup).*
  script: wsgi.application
  secure: always
  login: admin

- url: /.*
  script: wsgi.application
  secure: always

这里是background.yaml,除了实例类和缩放参数外,它与app.yaml相同:

application: myapp
module: background
version: 1-1
runtime: python27
api_version: 1
threadsafe: yes
instance_class: B1
basic_scaling:
  max_instances: 1
  idle_timeout: 10m

libraries:
- name: lxml
  version: "2.3"

handlers:
- url: /static
  static_dir: static

- url: /favicon\.ico
  static_files: static/img/favicon.ico
  upload: static/img/favicon.ico

- url: /_ah/(mapreduce|queue|warmup).*
  script: wsgi.application
  secure: always
  login: admin

- url: /(mapreduce|tasks).*
  script: wsgi.application
  secure: always
  login: admin

- url: /.*
  script: wsgi.application
  secure: always

当应用程序处于自动缩放模式时,/ _ah / start返回OK和HTTP代码200.当它处于基本缩放模式时,我在日志中看到的所有内容都是重复失败尝试到达/ _ah /以400开始HTTP代码。由于这些代码运行完全相同,我无法理解这里发生了什么。我可能错过了一些明显的东西......但是我看不到它。想法?

- 更新 -

当我使用curl在本地访问/_ah/start端点时,这是我看到的确切输出:

curl -i -X GET http://localhost:8000/_ah/start
HTTP/1.1 200 OK
content-type: text/html; charset=utf-8
Cache-Control: no-cache
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Content-Length: 3
Server: Development/2.0
Date: Fri, 24 Jun 2016 09:08:06 GMT

Ok.

...并在使用自动缩放设置时在服务器上:

curl -i -X GET https://myapp.appspot.com/_ah/start 
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Date: Fri, 24 Jun 2016 09:11:41 GMT
Server: Google Frontend
Content-Length: 3
Alternate-Protocol: 443:quic
Alt-Svc: quic=":443"; ma=2592000; v="34,33,32,31,30,29,28,27,26,25"

Ok.

...在服务器上设置基本缩放时,它就会挂起。

2 个答案:

答案 0 :(得分:0)

您的通配符处理程序正在接受对_ah/start的调用。您应该在background.yaml:

中为_ah/start添加处理程序
- url: /_ah/start
  script: background_starter.py
  login: admin

然后,您可以为200进行简单的返回。在background_starter.py中:

print 'Content-Type: text/plain'
print 'This is a dummy handler to return http 200, so you can use wildcard url mapping in app.yaml.'

答案 1 :(得分:0)

var autoprefixer = require('autoprefixer'); module.exports = { entry: { bundle: "./index.jsx" }, output: { path: __dirname, filename: "[name].js" }, module: { loaders: [ { test: /\.jsx$/, exclude: /(node_modules|bower_components)/, loaders: ['react-hot', 'babel-loader'] }, { test: /\.less$/, loader: ExtractTextPlugin.extract("style-loader", "css-loader!postcss-loader!less-loader") }, { test: /\.css$/, loader: ExtractTextPlugin.extract("style-loader", "css-loader!postcss-loader") } ], postcss: function () { return [autoprefixer]; } }, plugins: [ new webpack.BannerPlugin(banner), new ExtractTextPlugin("style.css") ], devtool: 'source-map', devServer: { stats: 'warnings-only', } }; 内置的处理程序似乎没有为此工作做必要的事情,我不确定是什么。与GAEfan的建议类似,我提供了一个处理程序,虽然他不允许应用程序在线程安全模式下运行,所以这里是我使用的djangae文件:

background_starter.py

...此处有import os import webapp2 from google.appengine.ext.webapp import template class MainPage(webapp2.RequestHandler): def get(self): self.response.out.write('{"status":"OK"}') app = webapp2.WSGIApplication([ ('/_ah/start', MainPage), ], debug=True) 文件的更新,将其视为独立应用:

.yaml