2013-11-03 60 views
6

我想用Heroku部署Flask應用程序。這是簡單的API。與領班合作很好,但在heroku上啓動時出現錯誤(日誌低於)。Flask應用程序不啓動在Heroku服務器上

這是我的應用程序代碼(我知道這可是在尋找一個塊,但我有問題,將其分割的文件):

import flask 
import flask.ext.sqlalchemy 
import flask.ext.restless 

app = flask.Flask(__name__) 
app.config['DEBUG'] = True 
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://user:[email protected]/db' 
db = flask.ext.sqlalchemy.SQLAlchemy(app) 


from sqlalchemy import Column, Integer, String, ForeignKey,\ 
    Date, DateTime, Boolean, Float 


class fruits(db.Model): 
    __tablename__ = 'fruits' 
    id = Column(Integer, primary_key=True) 
    name = Column(String(50),nullable=False) 
    calories = Column(Integer, nullable=False) 
    amount = Column(Integer, nullable=False) 
    unit = Column(String(10),nullable=False) 
    url = Column(String(100),nullable=True) 


@app.route('/') 
def hello_world(): 
    return 'Hello World!' 


# Create the database tables. 
db.create_all() 

# Create the Flask-Restless API manager. 
manager = flask.ext.restless.APIManager(app, flask_sqlalchemy_db=db) 

# Create API endpoints, which will be available at /api/<tablename> by 
# default. Allowed HTTP methods can be specified as well. 
manager.create_api(fruits, methods=['GET', 'POST', 'DELETE']) 
manager.create_api(tmp, methods=['GET', 'POST', 'DELETE']) 


# start the flask loop 

if __name__ == '__main__': 
     import os 
     port = int(os.environ.get('PORT', 33507)) 
     app.run(host='0.0.0.0', port=port) 

這是Heroku的日誌:

at=error code=H14 desc="No web processes running" method=GET path=/ host=blooming-taiga-1210.herokuapp.com fwd="188.33.19.82" dyno= connect= service= status=503 bytes= 

和我Procfile:

web: python __init__.py 
+0

你使用外部mysql服務器嗎? – zero323

回答

18

是否有實際運行DYNO叫web?它看起來像你可能忘記scale your web dyno

添加這樣一個條目在Procfile:

heroku ps:scale web=1 

您可以使用

heroku ps 

,以確認您的web測功機正在運行。

+1

當我在控制檯中執行它時,它在Procfile中無效。 謝謝! –

+0

我不能upvoting。以較少的聲譽;) –

+0

聖地獄,我不能相信這是不是在他們的部署文檔任何地方。 – Chris

相關問題