2017-10-08 34 views
0

正在苦苦寻找用于heroku工作的procfile。试图学习如何让一个基本的Django网站启动并运行,并从头开始构建一些东西。我用我的电脑上的窗户来修补所有使用服务员的决定,但也许gunicorn会更容易?Heroku的Procfile无法正常工作 - 使用女服务员的Django

如果我不能解决这个问题,我只会使用一个来自heroku的模板,并从中构建,但我宁愿不要摆脱迄今为止所做的工作。

这是我的目录结构。

Root +--- 
    .git 
    Include 
    Lib 
    Scripts 
    Scripts 
    Static 
    tcl 
    src +--- 
     � db.sqlite3 
     � manage.py 
     � 
     +---alex1 
     � � forms.py 
     � � settings.py 
     � � urls.py 
     � � wsgi.py 
     � � __init__.py 
     � � 
     � +---__pycache__ 
     �   settings.cpython-36.pyc 
     �   urls.cpython-36.pyc 
     �   wsgi.cpython-36.pyc 
     �   __init__.cpython-36.pyc 
     � 
     +---profiles 
      � admin.py 
      � apps.py 
      � forms.py 
      � models.py 
      � tests.py 
      � views.py 
      � __init__.py 
      � 
      +---migrations 
      � � 0001_initial.py 
      � � 0002_profile_description.py 
      � � 0003_auto_20170905_1654.py 
      � � 0004_auto_20170905_1659.py 
      � � __init__.py 
      � � 
      � +---__pycache__ 
      �   0001_initial.cpython-36.pyc 
      �   0002_profile_description.cpython-36.pyc 
      �   0003_auto_20170905_1654.cpython-36.pyc 
      �   0004_auto_20170905_1659.cpython-36.pyc 
      �   __init__.cpython-36.pyc 
      � 
      +---templates 
      �  base.html 
      �  contact.html 
      � 
      +---__pycache__ 
        admin.cpython-36.pyc 
        forms.cpython-36.pyc 
        models.cpython-36.pyc 
        views.cpython-36.pyc 
        __init__.cpython-36.pyc 

我收到的错误是这样

2017-10-08T09:33:38.547463+00:00 app[web.1]: There was an exception (ModuleNotFoundError) importing your module. 
2017-10-08T09:33:38.547464+00:00 app[web.1]: It had these arguments: 
2017-10-08T09:33:38.547464+00:00 app[web.1]: 1. No module named 'profiles' 

这是我procfile。

web: waitress-serve --port=$PORT profiles.wsgi:application 

谢谢大家 - 很欣赏你的帮助

回答

1

首先,你wsgi.py文件不在里面的src /型材里面的src/alex1。此外,女服务员没有找到您的应用配置文件因为不在python路径中。我不知道是否女服务员有一个参数添加的东西到PYTHONPATH(如gunicorn --pythonpath),但无论如何,你可以做这样的事情:

web: PYTHONPATH=$(pwd)'/src' waitress-serve --port=$PORT alex1.wsgi:application 

我和服务员工作,我可以没有看到使用它而不是gunicorn的改进。有人说这是更高性能的,但根据我的经验,使用起来更麻烦。

+0

这解决了我的问题!谢谢。如果我使用gunicorn,考虑到我正在从Windows开发,会不会很好?欢呼 –

+0

哎呀!没错,你不能使用gunicorn ......你的选择是女服务员(这已经工作,所以我会保留它)或在Heroku中使用gunicorn和本地开发使用manage.py runserver –

+1

好吧,所以我可以使用gunicorn,因为我没有在本地使用它?谢了哥们 –