Windows Azure网站python [英] Windows Azure Web sites python

查看:250
本文介绍了Windows Azure网站python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

经过一番艰苦的努力后,我终于得到了一个在Windows Azure上运行的Hello World应用程序,该应用程序在本地构建,运行正常,将其部署到Azure是一个噩梦。所以我在这里有两个问题。

我似乎无法得到一个堆栈跟踪,我已经尝试在web.config中设置的东西,但是关于如何使用所有这些东西的文档只是一堆乱七八糟的东西,我能找到的仅仅是写在微软数百万博客中的博客文章。这甚至没有帮助我解决我的问题。第二个问题涉及到第一个问题,由于一些可怕的调试方法(把我的应用程序分开和评论的东西)我觉得它可能是pymongo造成这一点,我已经建立它没有C扩展名,它在我的网站包,它在我的本地机器上工作。但是,没有堆栈跟踪,我不知道如何解决这个问题,而不想把我的头发拉出来。



任何人都可以点亮这个?真的令人失望,因为其余的天蓝色不是太糟糕了,更好的网站托管的替代品像英雄这是真正的10个命令的设置。到目前为止,我一直在为此工作。

解决方案

解决



对于那些有兴趣的人,我最终解决了这个问题,我手动添加错误处理到我的烧瓶应用程序完全绕过IIS设置和Windows Azure的配置 - 太复杂,根本没有文档。

  from werkzeug.debug import get_current_traceback 

@ app.errorhandler(500)
def internal_server_error(e):
ase = os.path.dirname(os.path.abspath(__ file__))
f = open('%s / logs / error.log'%(base),'a ')
track = get_current_traceback(skip = 1,show_hidden_​​frames = True,ignore_system_exceptions = False)
track.log(f)
f.close()

return '发生了错误',500


After a whole load of hard work I've eventually got a hello world flask app running on Windows Azure, the app is built locally and runs fine, deploying it to Azure is a nightmare though. So I've sort of got two questions here.

I can't seem to get a stack trace at all, I've tried setting things in web.config, but the documentation on how to use all this stuff is just apawling, all I can find is just literally badly written blog posts dotted around one of microsoft's millions of blogs. Which doesn't even help me to fix my problem.

The second question relates to the first one, due to some horrible debugging methods (taking my application apart and commenting things out) I feel like it could be pymongo causing this, I've built it without the C extensions and it's in my site-packages and it works on my local machine. However without a stack trace I've just no idea how to fix this without wanting to pull my hair out.

Can anyone shed some light on this? Really disappointing because the rest of azure isn't too bad, theres far better website hosting alternatives out there like heroku which are literally 10 command setups. I've been working on this all day so far..

解决方案

Solved

For those who are interested I ended up solving this problem my manually adding error handling into my flask application completely bypassing the IIS settings and windows azure configs - far too complicated with no documentation at all.

from werkzeug.debug import get_current_traceback   

@app.errorhandler(500)
def internal_server_error(e):
    base = os.path.dirname(os.path.abspath(__file__))
    f = open('%s/logs/error.log' % (base), 'a')
    track = get_current_traceback(skip=1, show_hidden_frames=True, ignore_system_exceptions=False)
    track.log(f)
    f.close()

    return 'An error has occured', 500

这篇关于Windows Azure网站python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆