antoinemartin / django-windows-tools

Django application providing management commands to host Django projects in Windows environments
BSD 2-Clause "Simplified" License
50 stars 13 forks source link

win7+python3.6+pyinstaller can run service, but no listening port #24

Closed tianxiawuzhe closed 6 years ago

tianxiawuzhe commented 7 years ago

python3.6(32bit)+django1.11.7+pyinstaller3.3+win7(64bit) it's a helloworld. i can 'python server.py install' and start, listening port is ok, i can visit by 'http://localhost:18800/hello', which will show json response. when i packed with pyinstaller, use [pyinstaller -n hello -y --add-data "hello\service.ini;." hello\service.py], and then run [dist\hello\hello.exe install] and start, no errors. i checked windows service state, it's running! but run [netstat -ano | findstr 18800], no result, and fail to visit url. what am i wrong ? or where the errors or exceptions are ? any suggestions ?

tianxiawuzhe commented 7 years ago

helloworld.zip

mrbean-bremen commented 7 years ago

Thanks for the report. I'm not sure what is going on here - I myself used only the winfcgi part with django 1.11/Python 3.6, so I have no experience here. Unfortunately, I currently don't have a system to check this, so this has to wait, but I will come back to this. Please let us know if you find anything!

mrbean-bremen commented 6 years ago

@tianxiawuzhe - I recently had a look at this, and I can confirm the problem. I didn't understand it though, but I suspect that this combination will not work. Having to experience with pyinstaller, this is just a guess - I may have another shot at this some time later, if this is still an issue for you.

tianxiawuzhe commented 6 years ago

I debug at 'start_django_command' function in 'django_windows_tools\service.py', it's not called. And refer 'https://stackoverflow.com/questions/24944558/pyinstaller-built-windows-exe-fails-with-multiprocessing'. I found solution: should add [multiprocessing.freeze_support()] to "main", like: if name == "main": multiprocessing.freeze_support() Thanks!

mrbean-bremen commented 6 years ago

Thanks - so this is a known pyinstaller caveat, good to know!