Django 应用程序引擎实例不以基本缩放开始,但可用于自动缩放
我正在尝试在AppEngine上启动一个具有基本缩放功能的项目,但无法启动。该应用程序可以自动缩放<代码>/\u ah/start在应用程序处于自动缩放状态时返回200。我不明白为什么应用程序只有在设置为自动缩放时才会启动 下面是Django 应用程序引擎实例不以基本缩放开始,但可用于自动缩放,django,google-app-engine,Django,Google App Engine,我正在尝试在AppEngine上启动一个具有基本缩放功能的项目,但无法启动。该应用程序可以自动缩放/\u ah/start在应用程序处于自动缩放状态时返回200。我不明白为什么应用程序只有在设置为自动缩放时才会启动 下面是app.yaml,这是一个非常标准的应用程序: application: myapp module: default version: 1-1 runtime: python27 api_version: 1 threadsafe: yes libraries: - name
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。当它处于基本缩放模式时,我在日志中看到的都是重复的失败尝试,以400 HTTP代码达到/_ah/开始。由于它们运行完全相同的代码,我无法理解这里发生了什么。我可能错过了一些明显的东西。。。但我看不见。想法
--更新--
这就是我使用curl
访问本地/\u 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.
。。。在服务器上设置基本缩放时,它只是挂起。您的通配符处理程序正在接受对
\u ah/start
的调用。您应该在background.yaml中为\u 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.'
您的通配符处理程序正在接受对
\u ah/start
的调用。您应该在background.yaml中为\u 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.'
djangae中内置的处理程序似乎没有做一些必要的工作,我不确定是什么。与GAEfan的建议类似,我提供了一个处理程序,尽管他的处理程序不允许应用程序在线程安全模式下运行,因此我使用的
background\u 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
文件的更新,将其视为一个独立的应用程序:
- url: /_ah/start
script: background_starter.app
secure: admin
djangae中内置的处理程序似乎没有做一些必要的工作,我不确定是什么。与GAEfan的建议类似,我提供了一个处理程序,尽管他的处理程序不允许应用程序在线程安全模式下运行,因此我使用的
background\u 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
文件的更新,将其视为一个独立的应用程序:
- url: /_ah/start
script: background_starter.app
secure: admin
没有
login:admin
,任何作恶者都可以启动您的后端实例。没有login:admin
,任何作恶者都可以启动您的后端实例。