Django - Application backend read Error

Repository of web frameworks and applications for Microsoft IIS.
User avatar
Posts: 2
Joined: 08 Nov 2014, 19:56

Django - Application backend read Error

08 Nov 2014, 20:08

Django on a clean Server 2012R2 instance (Amazon EC2)




Code: Select all

Error:
Helicon Zoo module has caught up an error. Please see the details below.

Worker Status:
The process was created

Windows error: 
The pipe has been ended. (ERROR CODE: 109)

Internal module error:   
message: Application backend read Error. type: ZooException file: App\Jobs\JobBase.cpp line: 531 version: 3.1.98.538

STDERR: 
Empty stderr

Environment variables: 
ALLUSERSPROFILE C:\ProgramData
APPDATA C:\Windows\system32\config\systemprofile\AppData\Roaming
APPL_ID ZooPythonProject
APPL_PHYSICAL_PATH C:\inetpub\wwwroot\ZooPythonProject
APPL_PHYSICAL_SHORT_PATH C:\inetpub\wwwroot\ZOOPYT~1
APPL_VIRTUAL_PATH /ZooPythonProject
APP_POOL_CONFIG C:\inetpub\temp\apppools\ZooPythonProject\ZooPythonProject.config
APP_POOL_ID ZooPythonProject
COMMONPROGRAMFILES C:\Program Files\Common Files
COMMONPROGRAMFILES(X86) C:\Program Files (x86)\Common Files
COMMONPROGRAMW6432 C:\Program Files\Common Files
COMPUTERNAME WIN-IAK09MB251B
COMSPEC C:\Windows\system32\cmd.exe
CONSOLE_URL console
DEPLOY_FILE deploy.py
DJANGO_SETTINGS_MODULE project.settings
ERROR_LOG_DIR log
FP_NO_HOST_CHECK NO
HOST 127.0.0.1
IIS_BINDNGS http=*:80:
INSTANCE_ID 1
LOCALAPPDATA C:\Windows\system32\config\systemprofile\AppData\Local
NUMBER_OF_PROCESSORS 1
OS Windows_NT
PATH C:\inetpub\wwwroot\ZooPythonProject\venv\Scripts;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Amazon\cfn-bootstrap\;C:\Program Files\Microsoft\Web Platform Installer\
PATHEXT .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE AMD64
PROCESSOR_IDENTIFIER Intel64 Family 6 Model 62 Stepping 4, GenuineIntel
PROCESSOR_LEVEL 6
PROCESSOR_REVISION 3e04
PROGRAMDATA C:\ProgramData
PROGRAMFILES C:\Program Files
PROGRAMFILES(X86) C:\Program Files (x86)
PROGRAMW6432 C:\Program Files
PSMODULEPATH C:\Windows\system32\WindowsPowerShell\v1.0\Modules\;C:\Program Files (x86)\AWS Tools\PowerShell\
PUBLIC C:\Users\Public
PYTHONPATH C:\inetpub\wwwroot\ZooPythonProject\venv\lib\site-packages;C:\inetpub\wwwroot\ZooPythonProject\venv\lib;C:\inetpub\wwwroot\ZooPythonProject;C:\inetpub\wwwroot\ZooPythonProject\project
SITE_NAME DEFAULT WEB SITE
SITE_PHYSICAL_PATH C:\inetpub\wwwroot
SYSTEMDRIVE C:
SYSTEMROOT C:\Windows
TEMP C:\Windows\TEMP
TMP C:\Windows\TEMP
USERDOMAIN WORKGROUP
USERNAME WIN-IAK09MB251B$
USERPROFILE C:\Windows\system32\config\systemprofile
VIRTUAL_ENV C:\inetpub\wwwroot\ZooPythonProject\venv
WINDIR C:\Windows

Helicon Zoo engine settings 

appName python.project
appFullPath C:\python27\python.exe
appDirectory C:\inetpub\wwwroot\ZooPythonProject
appArguments C:\Zoo\Workers\python\zoofcgi.py
deployArguments 
transportName NamedPipe
protocol fastcgi
scriptProcessor python.2.7.wsgi
errorLogDir C:\inetpub\wwwroot\ZooPythonProject\log
postBufferDir 
watchFileChangesMask 
host 127.0.0.1
port %PORT%
proxyPass 
minInstances 1
maxInstances 1
minRequestsPerWorker 3
maxRequestsPerWorker 15
portLower 49152
portUpper 65535
workerRequestTimeout 30
timeLimit 0
postBuffer 1024
memoryLimit 0
gracefulShutdownTimeout 30

Web.config variables 

APPL_ID ZooPythonProject
APPL_PHYSICAL_PATH C:\inetpub\wwwroot\ZooPythonProject
APPL_PHYSICAL_SHORT_PATH C:\inetpub\wwwroot\ZOOPYT~1
APPL_VIRTUAL_PATH /ZooPythonProject
CONSOLE_URL console
DEPLOY_FILE deploy.py
DJANGO_SETTINGS_MODULE project.settings
ERROR_LOG_DIR log
HOST 127.0.0.1
IIS_BINDNGS http=*:80:
INSTANCE_ID 1
PATH C:\inetpub\wwwroot\ZooPythonProject\venv\Scripts;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Amazon\cfn-bootstrap\;C:\Program Files\Microsoft\Web Platform Installer\
PYTHONPATH C:\inetpub\wwwroot\ZooPythonProject\venv\lib\site-packages;C:\inetpub\wwwroot\ZooPythonProject\venv\lib;C:\inetpub\wwwroot\ZooPythonProject;C:\inetpub\wwwroot\ZooPythonProject\project
SITE_NAME DEFAULT WEB SITE
SITE_PHYSICAL_PATH C:\inetpub\wwwroot
VIRTUAL_ENV C:\inetpub\wwwroot\ZooPythonProject\venv


Here is the worker error log:

Code: Select all

No handlers could be found for logger "django.request"
Traceback (most recent call last):
  File "C:\Zoo\Workers\python\zoofcgi.py", line 1069, in <module>
    run_django_app(options.django_settings_module, options.django_root)
  File "C:\Zoo\Workers\python\zoofcgi.py", line 999, in run_django_app
    FCGIServer(WSGIHandler(), app_root=django_root).run()
  File "C:\Zoo\Workers\python\zoofcgi.py", line 776, in run
    conn.run()
  File "C:\Zoo\Workers\python\zoofcgi.py", line 569, in run
    self.process_input()
  File "C:\Zoo\Workers\python\zoofcgi.py", line 600, in process_input
    self._do_stdin(rec)
  File "C:\Zoo\Workers\python\zoofcgi.py", line 724, in _do_stdin
    self._start_request(req)
  File "C:\Zoo\Workers\python\zoofcgi.py", line 697, in _start_request
    req.run()
  File "C:\Zoo\Workers\python\zoofcgi.py", line 515, in run
    protocolStatus, appStatus = self.server.handler(self)
  File "C:\Zoo\Workers\python\zoofcgi.py", line 862, in handler
    result = self.application(environ, start_response)
  File "C:\inetpub\wwwroot\ZooPythonProject\venv\lib\site-packages\django\core\handlers\wsgi.py", line 187, in __call__
    response = self.get_response(request)
  File "C:\inetpub\wwwroot\ZooPythonProject\venv\lib\site-packages\django\core\handlers\base.py", line 199, in get_response
    response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
  File "C:\inetpub\wwwroot\ZooPythonProject\venv\lib\site-packages\django\core\handlers\base.py", line 236, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "C:\inetpub\wwwroot\ZooPythonProject\venv\lib\site-packages\django\views\debug.py", line 91, in technical_500_response
    html = reporter.get_traceback_html()
  File "C:\inetpub\wwwroot\ZooPythonProject\venv\lib\site-packages\django\views\debug.py", line 350, in get_traceback_html
    return t.render(c)
  File "C:\inetpub\wwwroot\ZooPythonProject\venv\lib\site-packages\django\template\base.py", line 148, in render
    return self._render(context)
  File "C:\inetpub\wwwroot\ZooPythonProject\venv\lib\site-packages\django\template\base.py", line 142, in _render
    return self.nodelist.render(context)
  File "C:\inetpub\wwwroot\ZooPythonProject\venv\lib\site-packages\django\template\base.py", line 844, in render
    bit = self.render_node(node, context)
  File "C:\inetpub\wwwroot\ZooPythonProject\venv\lib\site-packages\django\template\debug.py", line 80, in render_node
    return node.render(context)
  File "C:\inetpub\wwwroot\ZooPythonProject\venv\lib\site-packages\django\template\debug.py", line 90, in render
    output = self.filter_expression.resolve(context)
  File "C:\inetpub\wwwroot\ZooPythonProject\venv\lib\site-packages\django\template\base.py", line 624, in resolve
    new_obj = func(obj, *arg_vals)
  File "C:\inetpub\wwwroot\ZooPythonProject\venv\lib\site-packages\django\template\defaultfilters.py", line 769, in date
    return format(value, arg)
  File "C:\inetpub\wwwroot\ZooPythonProject\venv\lib\site-packages\django\utils\dateformat.py", line 343, in format
    return df.format(format_string)
  File "C:\inetpub\wwwroot\ZooPythonProject\venv\lib\site-packages\django\utils\dateformat.py", line 35, in format
    pieces.append(force_text(getattr(self, piece)()))
  File "C:\inetpub\wwwroot\ZooPythonProject\venv\lib\site-packages\django\utils\dateformat.py", line 268, in r
    return self.format('D, j M Y H:i:s O')
  File "C:\inetpub\wwwroot\ZooPythonProject\venv\lib\site-packages\django\utils\dateformat.py", line 35, in format
    pieces.append(force_text(getattr(self, piece)()))
  File "C:\inetpub\wwwroot\ZooPythonProject\venv\lib\site-packages\django\utils\encoding.py", line 85, in force_text
    s = six.text_type(s)
  File "C:\inetpub\wwwroot\ZooPythonProject\venv\lib\site-packages\django\utils\functional.py", line 144, in __text_cast
    return func(*self.__args, **self.__kw)
  File "C:\inetpub\wwwroot\ZooPythonProject\venv\lib\site-packages\django\utils\translation\__init__.py", line 83, in ugettext
    return _trans.ugettext(message)
  File "C:\inetpub\wwwroot\ZooPythonProject\venv\lib\site-packages\django\utils\translation\trans_real.py", line 325, in ugettext
    return do_translate(message, 'ugettext')
  File "C:\inetpub\wwwroot\ZooPythonProject\venv\lib\site-packages\django\utils\translation\trans_real.py", line 306, in do_translate
    _default = translation(settings.LANGUAGE_CODE)
  File "C:\inetpub\wwwroot\ZooPythonProject\venv\lib\site-packages\django\utils\translation\trans_real.py", line 209, in translation
    default_translation = _fetch(settings.LANGUAGE_CODE)
  File "C:\inetpub\wwwroot\ZooPythonProject\venv\lib\site-packages\django\utils\translation\trans_real.py", line 189, in _fetch
    "The translation infrastructure cannot be initialized before the "
django.core.exceptions.AppRegistryNotReady: The translation infrastructure cannot be initialized before the apps registry is ready. Check that you don't make non-lazy gettext calls at import time.




ZooError-0-


Code: Select all
[08.11.2014 22:08:55.451521] [v 3.1.98.538] [tid 0x000008d8] [sev 2] # 29876311008 Application has been started
[08.11.2014 22:08:55.545260] [v 3.1.98.538] [tid 0x000008d8] [sev 2] # 29876234512 Application has been terminated
ate log file C:\inetpub\wwwroot\ZooPythonProject\log\python.project [2014_11_08 22_08_55] worker-1.log
[08.11.2014 22:08:56.154595] [v 3.1.98.538] [tid 0x00000a9c] [sev 2] WorkersManager - OnProcessExit()
[08.11.2014 22:08:56.154595] [v 3.1.98.538] [tid 0x00000a9c] [sev 2] WorkersManager - Worker shutdown. #2 - [pid:3276] "C:\python27\python.exe" C:\Zoo\Workers\python\zoofcgi.py
[08.11.2014 22:09:25.467110] [v 3.1.98.538] [tid 0x00000a9c] [sev 2] WorkersManager - Worker closed. #2
[08.11.2014 22:10:02.092102] [v 3.1.98.538] [tid 0x00000a9c] [sev 2] WorkersManager - OnProcessExit()
[08.11.2014 22:10:02.092102] [v 3.1.98.538] [tid 0x00000a9c] [sev 2] WorkersManager - Worker shutdown. #3 - [pid:2380] "C:\python27\python.exe" C:\Zoo\Workers\python\zoofcgi.py
[08.11.2014 22:10:25.467595] [v 3.1.98.538] [tid 0x00000a9c] [sev 2] WorkersManager - Worker closed. #3
[08.11.2014 22:13:34.654735] [v 3.1.98.538] [tid 0x00000a9c] [sev 2] WorkersManager - OnProcessExit()
[08.11.2014 22:13:34.654735] [v 3.1.98.538] [tid 0x00000a9c] [sev 2] WorkersManager - Worker shutdown. #4 - [pid:3852] "C:\python27\python.exe" C:\Zoo\Workers\python\zoofcgi.py
[08.11.2014 22:13:56.248576] [v 3.1.98.538] [tid 0x00000a9c] [sev 2] WorkersManager - Worker closed. #4
[08.11.2014 22:14:13.139178] [v 3.1.98.538] [tid 0x00000a9c] [sev 2] WorkersManager - OnProcessExit()
[08.11.2014 22:14:13.139178] [v 3.1.98.538] [tid 0x00000a9c] [sev 2] WorkersManager - Worker shutdown. #5 - [pid:2228] "C:\python27\python.exe" C:\Zoo\Workers\python\zoofcgi.py
[08.11.2014 22:14:26.342332] [v 3.1.98.538] [tid 0x00000a9c] [sev 2] WorkersManager - Worker closed. #5
[08.11.2014 22:16:54.342382] [v 3.1.98.538] [tid 0x00000a9c] [sev 2] WorkersManager - OnProcessExit()
[08.11.2014 22:16:54.342382] [v 3.1.98.538] [tid 0x00000a9c] [sev 2] WorkersManager - Worker shutdown. #6 - [pid:2496] "C:\python27\python.exe" C:\Zoo\Workers\python\zoofcgi.py
[08.11.2014 22:16:56.357999] [v 3.1.98.538] [tid 0x00000a9c] [sev 2] WorkersManager - Worker closed. #6



Django project settings.py:

Code: Select all
"""
Django settings for project project.

For more information on this file, see
https://docs.djangoproject.com/en/1.7/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.7/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '5jd%y7umf(o%0xa02nd@=(wl(z$$j#nyje^u=*19r*6kg$wfto'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

TEMPLATE_DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

ROOT_URLCONF = 'project.urls'

WSGI_APPLICATION = 'project.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

# Internationalization
# https://docs.djangoproject.com/en/1.7/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/

STATIC_URL = '/static/'



web.config


Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
 <system.webServer>
  <heliconZoo>
            <clear />
            <application name="python.project">
                <environmentVariables>
                    <add name="VIRTUAL_ENV" value="%APPL_PHYSICAL_PATH%\venv" />
                    <add name="PATH" value="%APPL_PHYSICAL_PATH%\venv\Scripts;%PATH%" />
                    <add name="PYTHONPATH" value="%APPL_PHYSICAL_PATH%\venv\lib\site-packages;%APPL_PHYSICAL_PATH%\venv\lib;%APPL_PHYSICAL_PATH%;%APPL_PHYSICAL_PATH%\project" />
                    <add name="CONSOLE_URL" value="console" />
                    <add name="DEPLOY_FILE" value="deploy.py" />
                    <add name="ERROR_LOG_DIR" value="log" />
                    <add name="DJANGO_SETTINGS_MODULE" value="project.settings" />
                </environmentVariables>
            </application>
  </heliconZoo>

  <handlers>

   <remove name="python.project#x86" />
   <remove name="python.project#x64" />
            <add name="python.project#x64" path="*" verb="*" modules="HeliconZoo_x64" scriptProcessor="python.2.7.wsgi" resourceType="Unspecified" requireAccess="Script" preCondition="bitness64" />
            <add name="python.project#x86" path="*" verb="*" modules="HeliconZoo_x86" scriptProcessor="python.2.7.wsgi" resourceType="Unspecified" requireAccess="Script" preCondition="bitness32" />

   <!-- Django or WSGI application over fastcgi -->
   

   <!-- HTTP backend (Tornado) over http -->
   <!--
   <add name="python.project#x86" scriptProcessor="python.2.7.http" path="*" verb="*" modules="HeliconZoo_x86" preCondition="bitness32" resourceType="Unspecified" requireAccess="Script" />
   <add name="python.project#x64" scriptProcessor="python.2.7.http" path="*" verb="*" modules="HeliconZoo_x64" preCondition="bitness64" resourceType="Unspecified" requireAccess="Script" />
    -->

   <!-- HTTP backend (Twisted) over http -->
   <!--
   <add name="python.project#x86" scriptProcessor="python.2.7.twisted" path="*" verb="*" modules="HeliconZoo_x86" preCondition="bitness32" resourceType="Unspecified" requireAccess="Script" />
   <add name="python.project#x64" scriptProcessor="python.2.7.twisted" path="*" verb="*" modules="HeliconZoo_x64" preCondition="bitness64" resourceType="Unspecified" requireAccess="Script" />
    -->
  </handlers>
 
 </system.webServer>
</configuration>



Any Ideas? Is there something I'm missing or can try?
Thank you!

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: Django - Application backend read Error

12 Nov 2014, 06:56

Hello,

It seems that you are trying to run the project for Django 1.6 on 1.7
You need to run Django via wsgi. To do that add the following into the web.config:


<add name="WSGI_APP" value="wsgi.application" />

Then create a file wsgi.py with the following content:

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

User avatar
Posts: 2
Joined: 08 Nov 2014, 19:56

Re: Django - Application backend read Error

15 Nov 2014, 04:05

Thanks for your post, although re-adding the wsgi line did not work; you did point me in the right direction, it definitively is a version issue.

When I installed django I just went
Code: Select all
pip install django


Figuring you guys were supreme wizards, I went right ahead and just installed the latest version of django.

Allas when is comes to servers, there is no magic, just meticulous work.

instead I installed 1.6:
Code: Select all
pip install django==1.6


Everything works perfectly now. I should have taken a hint from the guide provided to me, once python was installed, to install another version :P
I'm sure someone is working hard to get the newest version going. For me, it's not so crucial

Thanks again

User avatar
Posts: 1
Joined: 23 Feb 2015, 11:23

Re: Django - Application backend read Error

23 Feb 2015, 11:25

In the \Zoo\Workers\python\zoofcgi.py, I changed this:

Code: Select all
        from django.core.handlers.wsgi import WSGIHandler
        FCGIServer(WSGIHandler(), app_root=django_root).run()


for this:

Code: Select all
        from django.core.wsgi import get_wsgi_application
        FCGIServer(get_wsgi_application(), app_root=django_root).run()


and that solved the issue for me. Django 1.7 changed the way to get the wsgi module.

Does it seems a correct solution for you?

regards

Etienne

User avatar
Posts: 27
Joined: 13 Apr 2015, 03:03

Re: Django - Application backend read Error

13 Apr 2015, 03:24

Thanks you :)

Educa

Return to Helicon Zoo

Who is online

Users browsing this forum: No registered users and 14 guests