部署后AppEngine 500服务器错误 - 代码错误?

时间:2013-03-16 16:29:07

标签: google-app-engine

我知道有很多关于此错误的帖子,但我的问题确实看起来很独特,至少从我的角度来看。请证明我错了!我正在使用Python 2.7,通过from google.appengine.ext import db导入jinja2和db。我没有导入这些软件包的其他更简单的应用程序部署得很好,但是这个应用程序会抛出Error: Server Error。这可能与我的代码有关,或者这是Google的问题吗?现在看来这是一个常见的错误,但似乎也有很多诊断。但是,由于我的一些应用程序部署而非其他应用程序,这是可疑的。感谢。

- 一些额外的信息 -

正如我在评论中所说,本地运行正常,部署会引发服务器错误。

**本地运行后的日志输出:

*** Running dev_appserver with the following flags: --admin_console_server= --port=8080
Python command: /usr/local/bin/python2.7
WARNING  2013-03-17 03:06:52,527 dev_appserver.py:3578] The datastore file stub is 
deprecated, and will stop being the default in a future release.
Append the --use_sqlite flag to use the new SQLite stub.

You can port your existing data using the --port_sqlite_data flag or
purge your previous test data with --clear_datastore.

WARNING  2013-03-17 03:06:52,550 dev_appserver.py:3682] Could not initialize images API;
you are likely missing the Python "PIL" module. ImportError: No module named _imaging
INFO     2013-03-17 03:06:52,572 dev_appserver_multiprocess.py:656] Running application
dev~app1 on port 8080: http://localhost:8080
INFO     2013-03-17 03:06:52,572 dev_appserver_multiprocess.py:658] Admin console is
available at: http://localhost:8080/_ah/admin

**部署后的日志输出:

*** Running appcfg.py with the following flags:
--no_cookies --email=***@gmail.com --passin update
08:02 PM Host: appengine.google.com
08:02 PM Application: app1; version: 1
08:02 PM 
Starting update of app: app1, version: 1
08:02 PM Getting current resource limits.
08:02 PM Scanning files on local disk.
08:02 PM Cloning 1 static file.
08:02 PM Cloning 4 application files.
08:02 PM Compilation starting.
08:02 PM Compilation completed.
08:02 PM Starting deployment.
08:02 PM Checking if deployment succeeded.
08:02 PM Deployment successful.
08:02 PM Checking if updated app version is serving.
08:02 PM Completed update of app: app1, version: 1
Password for ***@gmail.com: 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 ***

- UPDATE-- 事实证明我有一个变量命名错误,当它被清除时,不再有500个服务器错误。我希望抛出的错误更具解释性,因为它们通常除了这个特殊情况之外。获得的经验教训 - 如果您发现自己处于这种情况,那么您的代码肯定是错误的。感谢大家的帮助。

3 个答案:

答案 0 :(得分:2)

App Engine 500(内部服务器错误)几乎总是意味着您的Python代码抛出了运行时捕获的无法处理的异常。当它捕获一个时,它会返回500响应。

答案 1 :(得分:0)

我正在Django视图中调用的html模板中引用js和css文件。这些css和js文件在我的应用程序中不存在。在本地主机上工作正常。但是server error 500在GAE上。

进入App Engine仪表板,查找错误-客户端错误,服务器错误。我在那里看到了我的CSS和JS文件错误。当您通过gcloud app logs tail -s default

查看终端中的日志时,这些错误不会显示

答案 2 :(得分:0)

当您的应用程序启动时出现问题时会发生这种情况, 所以最好的方法是查看日志,

检查日志的一种方法是 打开

 App Engine >> Services 
<块引用>

您将看到列出所有服务的表格,因此,在 “诊断”列有一个“工具”下拉菜单,打开下拉菜单并 选择“日志”。

也许您可以找到“为什么应用程序没有启动?”的根本原因。