Heroku的应用程序与Django和postgres意外崩溃 [英] Heroku app with Django and postgres crashing unexpectdly

查看:124
本文介绍了Heroku的应用程序与Django和postgres意外崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Django开发新手,但我处于需要在Heroku上部署大型项目的情况。



我在本地系统中运行我的应用程序,它工作得很好。



我把它推到Heroku,它也工作得很好。但几小时后,我在浏览器中打开我的应用程序URL,然后应用程序说有些事情已经破坏,暗示给管理员
应用程序在几个小时之前工作正常,但几小时后发生了什么。



我只是将旧的数据库备份推送到Heroku DB,这就是它的应用程序运行良好现在。

但我很困惑我的应用程序发生了什么,我一次又一次面对这个问题,
我怎么能在将来避免这个问题。

p>

我的应用配置:

  psycopg2 == 2.4.5 
Django == 1.4


解决方案

这可能是一些引起。这听起来更像是一个数据库问题。我会运行以下命令:

  heroku pg#使用HEROKU_POSTGRESQL_ [COLOR] _URL 

heroku pg:reset HEROKU_POSTGRESQL_ [COLOR] _URL --confirm [appname]

这会重置您的postgres数据库这是活动的,删除所有的表等。

然后我会运行常规命令来获得数据库备份和运行。

  manage.py syncdb 

您可以还可以做到以下几点:

  manage.py验证

这将通过您的模块并告诉您是否存在任何错误。



如果失败 - 在settings.py文件中启用调试。



您也可以运行heroku日志这会告诉你最近的几个错误和状态已被你的应用程序击中。



让我知道这是否有效,如果没有,我会帮助进一步调试。

I am new to Django development, but I am in a situation where I need to deploy a large project on Heroku.

I ran my app in local system, it worked fine.

I pushed the same to Heroku and it also worked fine. But after few hours I open my app URL in browser , then app is saying Some thing has broken,intimated to admin. The app worked fine before few hours, but what happened after few hours.

I just pushed my old DB backup to Heroku DB, Thats it app running fine now.

But I confused what happened to my app, I am facing this problem again and again, how can I avoid this problem in future.

My app configuration:

psycopg2==2.4.5
Django==1.4

解决方案

This could be a number of causes. It sounds more like a database issue. I would run the following command

heroku pg # TAKE NOTE OF THE HEROKU_POSTGRESQL_[COLOR]_URL

heroku pg:reset HEROKU_POSTGRESQL_[COLOR]_URL --confirm [appname]

This will reset your postgres database that is the active one, remove all tables etc.

Then I would run the regular command to get your database backup and running.

manage.py syncdb

You can also do the following

manage.py validate

This will go through your modules and tell you if any errors are present.

If that fails - enable debug in your settings.py file.

Also you can run "heroku logs" this will tell you the last few errors and statuses that have been hit with your app.

Let me know if this works, if not I will help debug further.

这篇关于Heroku的应用程序与Django和postgres意外崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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