【发布时间】:2015-05-10 15:20:24
【问题描述】:
我有一个带有 postgresql db 的烧瓶应用程序所以步骤是:
1.gunicorn
2.Procfile
3.heroku login
4.heroku apps:create flask-lili
5.heroku addons:add heroku-postgresql:dev
6.heroku pg:promote HEROKU_POSTGRESQL_ORANGE_URL
7.sudo pip install psycopg2
8.pip freeze> requirements.txt
10.git add .
11.git commit -m "create requirements.txt"
12.git push origin master
13.git push heroku master
14.heroku open
我运行命令 git push heroku master 时没有错误,但不确定我应该使用命令号 5 和 6 还是不使用
Procfile:
web: gunicorn manage:app
init: python manage.py db init
upgrade: python manage.py db upgrade
migrate: python manage.py db migrate
config.py:
class Config(object):
DEBUG = False
SECRET_KEY = 'Thisismysecretkey'
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL',
'postgresql+psycopg2://peg:1234@localhost/app')
print SQLALCHEMY_DATABASE_URI
class TestingConfig(Config):
DEBUG = True
TESTING = True
PRESERVE_CONTEXT_ON_EXCEPTION = False
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL',
'postgresql+psycopg2://peg:1234@localhost/testapp')
print SQLALCHEMY_DATABASE_URI
class DevelopmentConfig(Config):
DEBUG = True
class ProductionConfig(Config):
DEBUG = False
config = {
'development': DevelopmentConfig,
'testing': TestingConfig,
'production': ProductionConfig,
'default': DevelopmentConfig}
错误:
An error occurred in the application and your page could not be served. Please try again in a few moments.
If you are the application owner, check your logs for details.
如果你能帮助我,谢谢 现在我运行命令 heroku logs --tail:
2015-03-09T12:17:29.670249+00:00 heroku[api]: Enable Logplex by peg@gmail.com
2015-03-09T12:17:29.670286+00:00 heroku[api]: Release v2 created by peg1@gmail.com
2015-03-09T12:21:36.990904+00:00 heroku[web.1]: Starting process with command `gunicorn manage:app`
2015-03-09T12:21:38.880134+00:00 app[web.1]: bash: gunicorn: command not found
即使我的要求中有独角兽
如果我运行“heroku run init”会报错:
File "manage.py", line 3, in <module>
from flask.ext.migrate import Migrate, MigrateCommand
ImportError: No module named flask.ext.migrate
我可以毫无错误地在本地运行应用程序,并且我在 requirements.txt 中有烧瓶迁移
【问题讨论】:
-
能否请您添加一个记录器以便您可以使用
heroku --logs?您只需将应用程序日志记录到sys.stderr,Heroku 就会为您捕获它们 -
它不一定会帮助您上传应用程序,但它可以让您查看回溯,了解究竟出了什么问题。您可以使用this documentation 添加记录器。对于heroku,使用this logging hander to sys.stderr
-
gunicorn 步骤是什么意思?您的 requirements.txt 中有什么内容?
-
当人们使用
sudo来安装pip freeze并将其转储到需求文件中时,他们经常会得到很多他们不想要的东西。其中一些可能会导致问题。您的 requirements.txt 中有什么内容? -
我建议清理您的 requirements.txt。里面有很多东西,我敢肯定你的应用程序不会全部使用它们(例如,adium-theme-ubuntu)。我不知道这是问题所在,但如果 Heroku 无法安装某些东西,它可能会失败。
标签: python heroku flask heroku-postgres