从Cloud Playground部署测试python GAE应用程序时出错

时间:2014-01-07 21:22:08

标签: python google-app-engine deployment

我是SO的新手并且已尽可能多地阅读“我无法通过GAE app部署”条目,但必须在这里寻求帮助。在此先感谢您的帮助!

尝试部署 - 在将“CLOUDSQL_INSTANCE”变量编辑为我的实例名称后 - 添加到Cloud Playground的演示应用程序关于使用GCloud SQL实例处理示例留言簿应用程序(找到here)的数据。使用GAE Launcher App在GUI中使用“部署”按钮进行部署。尝试部署到MY-APP-ID.appspot.com(假设MY-APP-ID是,我知道,我的特定应用ID)。每次收到500错误消息:“服务器遇到错误,无法完成您的请求。 如果问题仍然存在,请报告您的问题并提及此错误消息以及导致该问题的查询。

当然,也许这段代码已经过时了,我只是走开了,应该尝试别的东西(?)。

的app.yaml

application: MY-APP-ID
version: 1
api_version: 1
runtime: python27
threadsafe: true

handlers:
- url: /favicon\.ico
  static_files: favicon.ico
  upload: favicon\.ico

- url: /.*
  script: main.application

libraries:
- name: webapp2
  version: "2.5.2"

main.py

import os

import logging
import webapp2

from google.appengine.api import app_identity
from google.appengine.api import rdbms

import jinja2

template_path = os.path.join(os.path.dirname(__file__))

jinja2_env = jinja2.Environment(
    loader=jinja2.FileSystemLoader(template_path)
)

APP_ID = aap_identity.get_application_id()
CLOUDSQL_INSTANCE = '{}:{}'.format(APP_ID, MY-INSTANCE-NAME)

DATABASE_NAME = 'guestbook'
USER_NAME = A-SECRET-USERNAME
PASSWORD = A-SECRET-PASSWORD


def get_connection():
    if os.environ['SERVER_SOFTWARE'].startswith('Development/'):
      return rdbms.connect(instance=CLOUDSQL_INSTANCE, database=DATABASE_NAME)
    else:
      return rdbms.connect(instance=CLOUDSQL_INSTANCE, database=DATABASE_NAME,
                           user=USER_NAME, password=PASSWORD, charset='utf8')


class MainHandler(webapp2.RequestHandler):
    def get(self):
        # Viewing guestbook
        conn = get_connection()
        cursor = conn.cursor()
        cursor.execute('SELECT guest_name, content, created_at FROM entries '
                       'ORDER BY created_at DESC limit 20')
        rows = cursor.fetchall()
        conn.close()
        template_values = {"rows": rows}
        template = jinja2_env.get_template('index.html')
        self.response.out.write(template.render(template_values))


class GuestBook(webapp2.RequestHandler):
    def post(self):
        # Posting a new guestbook entry
        conn = get_connection()
        cursor = conn.cursor()
        cursor.execute('INSERT INTO entries (guest_name, content) '
                       'VALUES (%s, %s)',
                       (self.request.get('guest_name'),
                        self.request.get("content")))
        conn.commit()
        conn.close()
        self.redirect("/")


application = webapp2.WSGIApplication([
    ("/", MainHandler),
    ("/sign", GuestBook),
], debug=True)

来自GAE Launcher的日志

*** Running appcfg.py with the following flags:
    --no_cookies --email=MY-EMAIL-ADDR --passin update
03:43 PM Application: MY-APP-ID; version: 1
03:43 PM Host: appengine.google.com
03:43 PM 
Starting update of app: MY-APP-ID, version: 1
03:43 PM Getting current resource limits.
03:43 PM Scanning files on local disk.
03:43 PM Cloning 1 static file.
03:43 PM Cloning 5 application files.
03:43 PM Uploading 2 files and blobs.
03:43 PM Uploaded 2 files and blobs
03:43 PM Compilation starting.
03:43 PM Compilation completed.
03:43 PM Starting deployment.
03:43 PM Checking if deployment succeeded.
03:43 PM Will check again in 1 seconds.
03:43 PM Checking if deployment succeeded.
03:43 PM Deployment successful.
03:43 PM Checking if updated app version is serving.
03:43 PM Completed update of app: MY-APP-ID, version: 1
Password for MY-EMAIL-ADDR: If deploy fails you might need to 'rollback' manually.
The "Make Symlinks..." menu option can help with command-line work.
*** appcfg.py has finished with exit code 0 ***

0 个答案:

没有答案
相关问题