Heroku,Django,工头
问题内容:
我正在关注本教程:http :
//tutorial.djangogirls.org/en/domain/README.html
但是当我foreman start web
按照https://devcenter.heroku.com/articles/getting-
started-with-python#run-the-app-
locally
在heroku文档中提到的方式运行时,出现此错误:
03:43:05 web.1 | started with pid 47516
03:43:05 web.1 | Traceback (most recent call last):
03:43:05 web.1 | File "C:\Python34\lib\runpy.py", line 170, in _run_module_as_main
03:43:05 web.1 | "__main__", mod_spec)
03:43:05 web.1 | File "C:\Python34\lib\runpy.py", line 85, in _run_code
03:43:05 web.1 | exec(code, run_globals)
03:43:05 web.1 | File "c:\Users\shenk\Documents\Programming\django_projects\djangogirls\myvenv\Scripts\gunicorn.exe\_
_main__.py", line 5, in <module>
03:43:05 web.1 | File "c:\Users\shenk\Documents\Programming\django_projects\djangogirls\myvenv\lib\site-packages\guni
corn\app\wsgiapp.py", line 10, in <module>
03:43:05 web.1 | from gunicorn.app.base import Application
03:43:05 web.1 | File "c:\Users\shenk\Documents\Programming\django_projects\djangogirls\myvenv\lib\site-packages\guni
corn\app\base.py", line 12, in <module>
03:43:05 web.1 | from gunicorn import util
03:43:05 web.1 | File "c:\Users\shenk\Documents\Programming\django_projects\djangogirls\myvenv\lib\site-packages\guni
corn\util.py", line 9, in <module>
03:43:05 web.1 | import fcntl
03:43:05 web.1 | ImportError: No module named 'fcntl'
03:43:05 web.1 | exited with code 1
03:43:05 system | sending SIGKILL to all processes
我应该使用工头吗?我读过,我应该使用gunicorn,但是我不确定如何使用它。我找不到如何使用gunicorn来启动服务器的任何示例,而不是heroku open
或python manage.py runserver
我读到gunicorn在Windows上不起作用…是真的吗?我找到了这个答案,但不确定如何实现。Windows上的fcntl替代品
假设我无法实现该fcntl替代品,那么Windows的解决方案是什么?我想尽可能使用gunicorn /
foreman,因为runserver仅用于开发。我一直在使用heroku,但是我不确定这是否是正确的方法。从Windows部署/启动服务器的正确方法是什么?还是Linux是唯一的选择?
问题答案:
Gunicorn不能在Windows上运行,因此您需要一个单独的系统来本地运行代码。您正在运行什么框架?
通常,您可以使用内置的开发服务器(例如Django的python manage.py
runserver)在本地进行开发,而仅在Heroku本身上使用gunicorn