Getting a FATAL Exited too quickly error. Supervisor configuration - django

I am getting this error when trying to configure Supervisor for a Django application on a VPS. So when I look at the error log it seems like it can't find the directory but I don't know what I am doing wrong here.
The path is:
/home/webconexus/portfolio
(portfolio) webconexus#wagtail-portfolio:~/portfolio$ sudo supervisorctl status
portfolio FATAL Exited too quickly (process log may have details
This is my gunicorn_start file:
#!/bin/bash
NAME="portfolio"
DIR=/home/webconexus/portfolio
USER=webconexus
GROUP=webconexus
WORKERS=3
BIND=unix:/home/webconexus/portfolio/run/gunicorn.sock
DJANGO_SETTINGS_MODULE=portfolio.settings
DJANGO_WSGI_MODULE=portfolio.wsgi
LOG_LEVEL=error
cd $DIR
source ../bin/activate
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
export PYTHONPATH=$DIR:$PYTHONPATH
exec ../bin/gunicorn ${DJANGO_WSGI_MODULE}:application \
--name $NAME \
--workers $WORKERS \
--user=$USER \
--group=$GROUP \
--bind=$BIND \
--log-level=$LOG_LEVEL \
--log-file=-
This is my conf file:
[program:portfolio]
command=/home/webconexus/portfolio/bin/gunicorn_start
directory=/home/webconexus/portfolio
user=webconexus
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/home/webconexus/portfolio/logs/gunicorn-error.log
The new error log:
[2019-02-07 12:58:20 +0000] [3835] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/home/webconexus/portfolio/lib/python3.5/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
worker.init_process()
File "/home/webconexus/portfolio/lib/python3.5/site-packages/gunicorn/workers/base.py", line 129, in init_process
self.load_wsgi()
File "/home/webconexus/portfolio/lib/python3.5/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
self.wsgi = self.app.wsgi()
File "/home/webconexus/portfolio/lib/python3.5/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/home/webconexus/portfolio/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
return self.load_wsgiapp()
File "/home/webconexus/portfolio/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
return util.import_app(self.app_uri)
File "/home/webconexus/portfolio/lib/python3.5/site-packages/gunicorn/util.py", line 350, in import_app
__import__(module)
ImportError: No module named 'portfolio'

No need to go back to ..
Try this
#!/bin/bash
NAME="portfolio"
DIR=/home/webconexus/portfolio
USER=webconexus
GROUP=webconexus
WORKERS=3
BIND=unix:/home/webconexus/portfolio/run/gunicorn.sock
DJANGO_SETTINGS_MODULE=portfolio.settings
DJANGO_WSGI_MODULE=portfolio.wsgi
LOG_LEVEL=error
cd $DIR
source ./bin/activate
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
export PYTHONPATH=$DIR:$PYTHONPATH
exec ./bin/gunicorn ${DJANGO_WSGI_MODULE}:application \
--name $NAME \
--workers $WORKERS \
--user=$USER \
--group=$GROUP \
--bind=$BIND \
--log-level=$LOG_LEVEL \
--log-file=-

Related

Wagtail: wrong filepath when I compile the project

I am trying to upgrade Wagtail from 1.13 to 2.0 and I get this error when trying to migrate:
RuntimeError: Model class wagtail.wagtailcore.models.Site doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
And log is:
[...]
File "C: \ Program Files \ Python36 \ lib \ site-packages \ wagtail \ wagtailcore \ blocks \ field_block.py", line 16, in <module>
from wagtail.wagtailcore.rich_text import RichText
File "C: \ Program Files \ Python36 \ lib \ site-packages \ wagtail \ wagtailcore \ rich_text.py", line 10, in <module>
from wagtail.wagtailcore.models import Page
File "C: \ Program Files \ Python36 \ lib \ site-packages \ wagtail \ wagtailcore \ models.py", line 54, in <module>
class Site (models.Model):
File "C: \ Program Files \ Python36 \ lib \ site-packages \ django \ db \ models \ base.py", line 118, in __new__
"INSTALLED_APPS." % (module, name)
RuntimeError: Model class wagtail.wagtailcore.models.Site doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
I have previously installed everything necessary for the update and I have passed the script to rename the changed fields.
In the log you can see that the path that should point to the core actually points to the old version (wagtailcore) instead of "core":
C: \ Program Files \ Python36 \ lib \ site-packages \ wagtail \ wagtailcore \ models.py
I think all the problems come from here, how do I do to django to look in the correct folder?
UPDATE:
I tried to uninstall with pip uninstall wagtail but some folders weren't deleted:
result post uninstall
And command throws this error:
Exception:
Traceback (most recent call last):
File "c:\program files\python36\lib\shutil.py", line 550, in move
os.rename(src, real_dst)
FileNotFoundError: [WinError 3] El sistema no puede encontrar la ruta especificada: 'c:\\program files\\python36\\lib\\site-packages\\wagtail\\tests\\testapp\\migrations\\__pycache__\\0005_customrichblockfieldpage_customrichtextfieldpage_defaultrichblockfieldpage_defaultrichtextfieldpage.cpython-36.pyc' -> 'C:\\Users\\plata\\AppData\\Local\\Temp\\pip-uninstall-v6wl_qyt\\program files\\python36\\lib\\site-packages\\wagtail\\tests\\testapp\\migrations\\__pycache__\\0005_customrichblockfieldpage_customrichtextfieldpage_defaultrichblockfieldpage_defaultrichtextfieldpage.cpython-36.pyc'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\program files\python36\lib\site-packages\pip\_internal\cli\base_command.py", line 143, in main
status = self.run(options, args)
File "c:\program files\python36\lib\site-packages\pip\_internal\commands\uninstall.py", line 75, in run
auto_confirm=options.yes, verbose=self.verbosity > 0,
File "c:\program files\python36\lib\site-packages\pip\_internal\req\req_install.py", line 683, in uninstall
uninstalled_pathset.remove(auto_confirm, verbose)
File "c:\program files\python36\lib\site-packages\pip\_internal\req\req_uninstall.py", line 224, in remove
renames(path, new_path)
File "c:\program files\python36\lib\site-packages\pip\_internal\utils\misc.py", line 280, in renames
shutil.move(old, new)
File "c:\program files\python36\lib\shutil.py", line 564, in move
copy_function(src, real_dst)
File "c:\program files\python36\lib\shutil.py", line 263, in copy2
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "c:\program files\python36\lib\shutil.py", line 121, in copyfile
with open(dst, 'wb') as fdst:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\plata\\AppData\\Local\\Temp\\pip-uninstall-v6wl_qyt\\program files\\python36\\lib\\site-packages\\wagtail\\tests\\testapp\\migrations\\__pycache__\\0005_customrichblockfieldpage_customrichtextfieldpage_defaultrichblockfieldpage_defaultrichtextfieldpage.cpython-36.pyc'
The wagtailcore app folder doesn't exist at all in Wagtail 2.0's codebase, so it looks like you still have the old version of Wagtail installed. Try running pip uninstall wagtail, and confirm that the C:\Program Files\Python36\lib\site-packages\wagtail folder has been properly deleted before running pip install wagtail==2.0.2.

ImportError: The curl client requires the pycurl library Docker + Django

I'm dockerizing Django 2.2 application and using Pipenv for environment management.
I want to use SQS as broker with Django celery.
I have installed the pycurl library using Pipenv
[packages]
...
pycurl = "*"
When I run celery locally
pipenv run celery -A qcg worker -l info
It works but when I run using docker image
docker run app:latest celery -A qcg worker -l info
It gives error
ImportError: The curl client requires the pycurl library.
The command in Docerkfile used to install dependencies
RUN set -ex \
&& BUILD_DEPS=" \
build-essential \
libpcre3-dev \
libpq-dev \
libcurl4-openssl-dev libssl-dev \
" \
&& apt-get update && apt-get install -y --no-install-recommends $BUILD_DEPS \
&& export PYCURL_SSL_LIBRARY=nss \
&& pipenv install --deploy --system \
\
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $BUILD_DEPS
\
&& rm -rf /var/lib/apt/lists/*
Complete error log
[2020-05-25 17:16:22,216: CRITICAL/MainProcess] Unrecoverable error: ImportError('The curl client requires the pycurl library.')
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/kombu/asynchronous/http/__init__.py", line 20, in get_client
return hub._current_http_client
AttributeError: 'Hub' object has no attribute '_current_http_client'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/celery/worker/worker.py", line 205, in start
self.blueprint.start(self)
File "/usr/local/lib/python3.7/site-packages/celery/bootsteps.py", line 119, in start
step.start(parent)
File "/usr/local/lib/python3.7/site-packages/celery/bootsteps.py", line 369, in start
return self.obj.start()
File "/usr/local/lib/python3.7/site-packages/celery/worker/consumer/consumer.py", line 318, in start
blueprint.start(self)
File "/usr/local/lib/python3.7/site-packages/celery/bootsteps.py", line 119, in start
step.start(parent)
File "/usr/local/lib/python3.7/site-packages/celery/worker/consumer/consumer.py", line 599, in start
c.loop(*c.loop_args())
File "/usr/local/lib/python3.7/site-packages/celery/worker/loops.py", line 83, in asynloop
next(loop)
File "/usr/local/lib/python3.7/site-packages/kombu/asynchronous/hub.py", line 301, in create_loop
item()
File "/usr/local/lib/python3.7/site-packages/vine/promises.py", line 170, in __call__
return self.throw()
File "/usr/local/lib/python3.7/site-packages/vine/promises.py", line 167, in __call__
retval = fun(*final_args, **final_kwargs)
File "/usr/local/lib/python3.7/site-packages/kombu/transport/SQS.py", line 390, in _schedule_queue
queue, callback=promise(self._loop1, (queue,)),
File "/usr/local/lib/python3.7/site-packages/kombu/transport/SQS.py", line 406, in _get_bulk_async
return self._get_async(queue, maxcount, callback=callback)
File "/usr/local/lib/python3.7/site-packages/kombu/transport/SQS.py", line 416, in _get_async
qname, count=count, connection=self.asynsqs(queue=qname),
File "/usr/local/lib/python3.7/site-packages/kombu/transport/SQS.py", line 566, in asynsqs
region=self.region
File "/usr/local/lib/python3.7/site-packages/kombu/asynchronous/aws/sqs/connection.py", line 27, in __init__
**kwargs
File "/usr/local/lib/python3.7/site-packages/kombu/asynchronous/aws/connection.py", line 194, in __init__
**http_client_params)
File "/usr/local/lib/python3.7/site-packages/kombu/asynchronous/aws/connection.py", line 151, in __init__
self._httpclient = http_client or get_client()
File "/usr/local/lib/python3.7/site-packages/kombu/asynchronous/http/__init__.py", line 22, in get_client
client = hub._current_http_client = Client(hub, **kwargs)
File "/usr/local/lib/python3.7/site-packages/kombu/asynchronous/http/__init__.py", line 13, in Client
return CurlClient(hub, **kwargs)
File "/usr/local/lib/python3.7/site-packages/kombu/asynchronous/http/curl.py", line 43, in __init__
raise ImportError('The curl client requires the pycurl library.')
ImportError: The curl client requires the pycurl library.
I was getting the same error and this worked for me: pip install celery[sqs]
This issue was with the libcurl4-nss-dev libssl-dev installation.
In the following installation script
RUN set -ex \
&& BUILD_DEPS=" \
build-essential \
libpcre3-dev \
libpq-dev \
libcurl4-openssl-dev libssl-dev \
" \
&& apt-get update && apt-get install -y --no-install-recommends $BUILD_DEPS \
&& export PYCURL_SSL_LIBRARY=nss \
&& pipenv install --deploy --system \
\
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $BUILD_DEPS
\
&& rm -rf /var/lib/apt/lists/* ```
The libcurl4-nss-dev libssl-dev installation is removed after the Pipenv install. So the package library couldn't be located.
After separating installation of libcurl4-nss-dev libssl-dev works for me.
RUN apt-get install -y --no-install-recommends libcurl4-nss-dev libssl-dev

Dockerizing Django application: ModuleNotFoundError: No module named 'X"

I've been trying to follow this guide to Dockerize a project:
Deploy and Run Django in Dokcer Container
This is the base file structure:
WFMBCM
|-WFMBCM
| |-__init__.py
| |-__pycache__
| |-setting.py
| |-url.py
| |-wsgi.py
|
|-WFMBCM_App
|-WFMBCM_db
|-manage.py
|-Dockerfile
|-requirements.txt
|-runWFMBCM.sh
Dockerfile:
FROM python:3.7
ADD WFMBCM /usr/src/app
ADD WFMBCM_App /usr/src/app
ADD WFMBCM_db /usr/src/app
ADD manage.py /usr/src/app
WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
EXPOSE 8000
CMD exec gunicorn wfmbcm.wsgi:application --bind 0.0.0.0:8000 --workers 3
requirements.txt:
Django==2.2.1
gunicorn==19.9.0
runWFMBCM.sh:
cd /home/admin/WFMBCM
echo -e "\033[0;34mGo to WFMBCM directory.\n \033[0;37m"
echo -e "\033[0;34mRemove old WFMBCM container\n \033[0;37m"
docker rm -v wfmbcm_container
echo -e "\033[0;34m\nBuild WFMBCM Docker image.\n \033[0;37m"
sudo docker build -t wfmbcm .
echo -e "\033[0;34m\nRun WFMBCM Docker image.\n \033[0;37m"
sudo docker run --name wfmbcm_container -p 8000:8000 -i -t wfmbcm
echo -e "\033[0;34m\n\nWFMBCM run-script ended!.\n \033[0;37m"
When I run runWFMBCM.sh I get the following output:
Go to WFMBCM directory.
Remove old WFMBCM container
Error response from daemon: No such container: wfmbcm_container
Build WFMBCM Docker image.
Sending build context to Docker daemon 265.2kB
Step 1/10 : FROM python:3.7
---> cc971a68c3e4
Step 2/10 : ADD WFMBCM /usr/src/app
---> Using cache
---> 302346d017e2
Step 3/10 : ADD WFMBCM_App /usr/src/app
---> Using cache
---> 18bc8eb69946
Step 4/10 : ADD WFMBCM_db /usr/src/app
---> Using cache
---> 0835393b22dc
Step 5/10 : ADD manage.py /usr/src/app
---> Using cache
---> 3ef5477e4b26
Step 6/10 : WORKDIR /usr/src/app
---> Using cache
---> 2edb019a8257
Step 7/10 : COPY requirements.txt ./
---> Using cache
---> df3ac922b7a0
Step 8/10 : RUN pip install --no-cache-dir -r requirements.txt
---> Using cache
---> ba6cf54e7dcc
Step 9/10 : EXPOSE 8000
---> Using cache
---> 94f3f4fb38c0
Step 10/10 : CMD exec gunicorn wfmbcm.wsgi:application --bind 0.0.0.0:8000 --workers 3
---> Using cache
---> db6cf2149949
Successfully built db6cf2149949
Successfully tagged wfmbcm:latest
Run WFMBCM Docker image.
[2019-05-26 09:59:36 +0000] [1] [INFO] Starting gunicorn 19.9.0
[2019-05-26 09:59:36 +0000] [1] [INFO] Listening at: http://0.0.0.0:8000 (1)
[2019-05-26 09:59:36 +0000] [1] [INFO] Using worker: sync
[2019-05-26 09:59:36 +0000] [9] [INFO] Booting worker with pid: 9
[2019-05-26 09:59:36 +0000] [10] [INFO] Booting worker with pid: 10
[2019-05-26 09:59:36 +0000] [9] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
worker.init_process()
File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process
self.load_wsgi()
File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
self.wsgi = self.app.wsgi()
File "/usr/local/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
return self.load_wsgiapp()
File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/local/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app
__import__(module)
ModuleNotFoundError: No module named 'wfmbcm'
[2019-05-26 09:59:36 +0000] [9] [INFO] Worker exiting (pid: 9)
[2019-05-26 09:59:36 +0000] [11] [INFO] Booting worker with pid: 11
[2019-05-26 09:59:36 +0000] [10] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
worker.init_process()
File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process
self.load_wsgi()
File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
self.wsgi = self.app.wsgi()
File "/usr/local/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
return self.load_wsgiapp()
File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/local/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app
__import__(module)
ModuleNotFoundError: No module named 'wfmbcm'
[2019-05-26 09:59:36 +0000] [10] [INFO] Worker exiting (pid: 10)
[2019-05-26 09:59:36 +0000] [11] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
worker.init_process()
File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process
self.load_wsgi()
File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
self.wsgi = self.app.wsgi()
File "/usr/local/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
return self.load_wsgiapp()
File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/local/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app
__import__(module)
ModuleNotFoundError: No module named 'wfmbcm'
[2019-05-26 09:59:36 +0000] [11] [INFO] Worker exiting (pid: 11)
[2019-05-26 09:59:37 +0000] [1] [INFO] Shutting down: Master
[2019-05-26 09:59:37 +0000] [1] [INFO] Reason: Worker failed to boot.
WFMBCM run-script ended!.
Why can't it find wfmbcm module? I've been staring crazy and googling without success and looking at different stack overflow questions.
I can't find any python module named wfmbcm, so I assume that it's an app in your project.
If you are on a case sensitive file system, then your file layout shows all caps for some folders and that might be (part of) the issue.
Does this project run outside of docker?
If it does, then I think that your best bet is to start the docker container and then manually install the entire app inside the container, updating the dockerfile with the steps as you go.
Every time you test a new change, make sure that you build with the --no-cache option or you may not be testing what you think you are.
Changing my DockerFile to this solved my issue:
FROM python:3.7
ADD WFMBCM /usr/src/app/WFMBCM
ADD WFMBCM_App /usr/src/app/WFMBCM_App
ADD WFMBCM_db /usr/src/app/WFMBCM_db
ADD manage.py /usr/src/app
WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
EXPOSE 8000
CMD manage.py migrate
CMD exec gunicorn WFMBCM.wsgi:application --bind 0.0.0.0:8000 --workers 10
Just Copy WFMBCM/WFMBCM/wsgi.py file in the root of project (so wsgi.py path is WFMBCM/wsgi.py)
and change CMD exec ... to this CMD exec gunicorn wsgi:application --bind 0.0.0.0:8000 --workers 3
and you'll be fine to go.

Django CMS + uWSGI + virtualenv + socket causing PendingDeprecationWarning error in uWSGI logs

Here's the error:
Traceback (most recent call last):
File "/var/apps/tango/envs/tango-env/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 187, in __call__
self.load_middleware()
File "/var/apps/tango/envs/tango-env/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 45, in load_middleware
mw_class = import_by_path(middleware_path)
File "/var/apps/tango/envs/tango-env/local/lib/python2.7/site-packages/django/utils/module_loading.py", line 21, in import_by_path
module = import_module(module_path)
File "/var/apps/tango/envs/tango-env/local/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
__import__(name)
File "/var/apps/tango/envs/tango-env/local/lib/python2.7/site-packages/django/middleware/doc.py", line 4, in <module>
warnings.warn(__doc__, PendingDeprecationWarning, stacklevel=2)
TypeError: expected string or buffer
TypeError: expected string or buffer
Tango is the user I created specifically for this project.
I'm using upstart so in /etc/init/tango-wsgi.conf looks like:
exec /var/apps/tango/envs/tango-env/bin/uwsgi \
--uid tango \
--home /var/apps/tango/envs/tango-env \
--pythonpath /var/apps/tango/tango/src \
--wsgi-file /var/apps/tango/tango/src/tango_cms/wsgi.py \
--socket /tmp/tango-uwsgi.sock \
--chmod-socket \
--logdate \
--optimize 2 \
--processes 2 \
--master \
--logto /var/apps/tango/logs/uwsgi.log
UPDATE:
My nginx.conf has following entry:
location / {
uwsgi_pass unix:/tmp/tango-uwsgi.sock;
include /etc/nginx/uwsgi_params;
}
Please help.
Same problem here. I fixed it deleting the following line on tango-wsgi.conf file:
--optimize 2 \
Optimize allows some kind of python optimization: More info
Not sure why it's an error, you could try removing "XViewMiddleware" if it's installed.

Running gunicrn_start.sh with --preload: Error Empty module name

I have a django project set up, with gunicorn. I have the following gunicorn_start:
#! /bin/bash
NAME="ostabs2"
DJANGODIR=/srv/osmium/ostabs2
SOCKFILE=/srv/osmium/run/gunicorn.sock
USER=tabuser
GROUP=webapps
NUM_WORKERS=3
DJANGO_SETTINGS_MODULE=ostabs2.settings
DANGO_WSGI_MODULE=ostabs2.wsgi
echo "Starting $NAME as 'whoami'"
cd $DJANGODIR
source /srv/osmium/venv/bin/activate
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
export PYTHONPATH=$DJANGODIR:$PYTHONPATH
exec gunicorn ${DJANGO_WSGI_MODULE}:application \
--preload \
--name $NAME \
--workers $NUM_WORKERS \
--user=$USER --group=$GROUP \
--log-level=debug \
--bind=unix:$SOCKFILE \
--log-file=ostabsgun.log
Running
gunicorn ostabs2.wsgi:application
on the command line works fine, but the gunicorn_start script gives:
Traceback (most recent call last):
File "/srv/osmium/venv/bin/gunicorn", line 11, in <module>
sys.exit(run())
File "/srv/osmium/venv/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 74, in run
WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
File "/srv/osmium/venv/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 185, in run
super(Application, self).run()
File "/srv/osmium/venv/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 71, in run
Arbiter(self).run()
File "/srv/osmium/venv/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 57, in __init__
self.setup(app)
File "/srv/osmium/venv/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 113, in setup
self.app.wsgi()
File "/srv/osmium/venv/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 66, in wsgi
self.callable = self.load()
File "/srv/osmium/venv/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
return self.load_wsgiapp()
File "/srv/osmium/venv/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
return util.import_app(self.app_uri)
File "/srv/osmium/venv/local/lib/python2.7/site-packages/gunicorn/util.py", line 356, in import_app
__import__(module)
ValueError: Empty module name
What would cause this error? Is there an error in the project, or a missing dependency? I have checked user permissions on all files and directories and tabuser has full read/write access. How can I track down the cause of this problem?
UPDATE: I have followed the advice from this question, the database definitions are correct (I can run syyncdb both locally and on the server). There are no empty strings in the installed apps section, and I have removed references throughout the app to libraries which are no longer used.
Is there anything else which can cause this error?