Script timed out before returning headers: wsgi.py on elastic beanstalk

后端 未结 6 1141
后悔当初
后悔当初 2020-12-14 07:45

I\'m trying to deploy a Django application to Elastic Beanstalk. When I visit the page it never loads. The logs say:

Script timed out before returning header         


        
6条回答
  •  猫巷女王i
    2020-12-14 08:46

    I had this problem until I realized that I was using a different Python version. Let me explain this. I was using a CentOS 7. The default Python version in CentOS 7 is Python 2.7, but my code use Python 3.6, so I installed Python 3.6 in the same machine by doing this:

    sudo yum install centos-release-scl
    sudo yum install rh-python36 rh-python36-python-pip rh-python36-python-virtualenv
    scl enable rh-python36 bash
    

    Then created a virtual environment and used it in WSGI:

        WSGIScriptAlias   / /var/www/myproject/myproject/wsgi.py
        WSGIDaemonProcess myproject python-home=/var/www/myproject python-path=/var/www/myproject:/var/www/myproject/lib/python3.6/site-packages
        WSGIProcessGroup  myproject    
    

    And the "script timed out" problem appeared. Then I realize that the mod_wsgi.so was compiled against libpython2.7.so.1.0.

    # ldd /usr/lib64/httpd/modules/mod_wsgi.so
    linux-vdso.so.1 =>  (0x00007ffd3fcae000)
    libpython2.7.so.1.0 => /lib64/libpython2.7.so.1.0 (0x00007f1240cd4000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f1240ab8000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007f12408b3000)
    libutil.so.1 => /lib64/libutil.so.1 (0x00007f12406b0000)
    libm.so.6 => /lib64/libm.so.6 (0x00007f12403ae000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f123ffe0000)
    /lib64/ld-linux-x86-64.so.2 (0x00005598a5aac000)
    

    The solution was removing mod_wsgi package and installing rh-python36-mod_wsgi package.

    Best regards!

提交回复
热议问题