Running channels with django 1.9 on an ec2 ubunutu.
Starting channels and workers on a bash script
NAME="snagfin_real_engine" # Name of the application
DJANGODIR=/webapps/novuu/snagfin # Django project directory
USER=novuu_admin # the user to run as
GROUP=webapps # the group to run as
NUM_WORKERS=3 # how many worker processes s$
DJANGO_SETTINGS_MODULE=snagfin.settings.prod # which settings file $
DJANGO_ASGI_MODULE=snagfin.asgi # WSGI module name
echo "Starting $NAME as whoami"
cd $DJANGODIR
source ../bin/activate
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
export PYTHONPATH=$DJANGODIR:$PYTHONPATH
python manage.py runworker --only-channels=websocket.*
daphne -u /tmp/daphne.sock snagfin.asgi:channel_layer
which is called by supervisor as such
[program:rengine]
command = /webapps/novuu/bin/real_engine_start
user = novuu_admin
stdout_logfile = /webapps/novuu/logs/real_supervisor.log
redirect_stderr = true
environment=LANG=en_US.UTF-8,LC_ALL=en_US.UTF-8
The above setup doesn't generate the .sock file in /temp/ even though supervisor goes through.
Supervisor real log
/webapps/novuu/snagfin/snagfin/urls.py:24: RemovedInDjango110Warning: Support for string view arguments to url() is deprecated and will be removed in Django 1.10 (got allauth.account.views.login). Pass the callable instead.
url(r'^login/$', 'allauth.account.views.login'),
/webapps/novuu/local/lib/python2.7/site-packages/jfu/templatetags/jfutags.py:1: RemovedInDjango110Warning: django.core.context_processors is deprecated in favor of django.template.context_processors.
from django.core.context_processors import csrf
2016-10-25 06:55:46,341 - INFO - runworker - Using single-threaded worker.
2016-10-25 06:55:46,342 - INFO - runworker - Running worker against channel layer default (asgi_redis.core.RedisChannelLayer)
2016-10-25 06:55:46,342 - INFO - worker - Listening on channels websocket.connect, websocket.receive
I'm afraid I can't help debug individual problems like this with too much detail - maybe someone else will come along and help,
It's possible your system doesn't list unix sockets - have you tried opening it with a socket utility by path to check if it's there?
As example it is my supervisor .conf for Daphne.
Maybe it can help somebody:
(ussual I store nginx and supervisor .conf files in project/conf folder, you will allow to asy update confs with git or another deployment way)
/project/conf/supervisor/opentaxi.conf
# ====================================================
[program:opentaxi-worker-1]
environment=DJANGO_SETTINGS_MODULE="settings.base",
PYTHONIOENCODING="UTF-8",
LANG="ru_RU.UTF-8",
LC_ALL="ru_RU.UTF-8",
LC_LANG="ru_RU.UTF-8",
SECRET_KEY="*********",
DB_NAME="opentaxi",
DB_USER="postgres",
DB_PASSWORD="*********",
DB_HOST="localhost",
DB_PORT="5432"
command=/root/virtualenvs/opentaxi/bin/python manage.py runworker
directory = /root/www/opentaxi/src
user=root
group=www-data
autorestart=true
stderr_logfile = /root/www/log/opentaxi/workers_errors.log
# ===============================================
[program:opentaxi-worker-2]
environment=DJANGO_SETTINGS_MODULE="settings.base",
PYTHONIOENCODING="UTF-8",
LANG="ru_RU.UTF-8",
LC_ALL="ru_RU.UTF-8",
LC_LANG="ru_RU.UTF-8",
SECRET_KEY="*********",
DB_NAME="opentaxi",
DB_USER="postgres",
DB_PASSWORD="*********",
DB_HOST="localhost",
DB_PORT="5432"
command=/root/virtualenvs/opentaxi/bin/python manage.py runworker
directory = /root/www/opentaxi/src
user=root
group=www-data
autorestart=true
stderr_logfile = /root/www/log/opentaxi/workers_errors.log
# ===================================================
[program:opentaxi-worker-3]
environment=DJANGO_SETTINGS_MODULE="settings.base",
PYTHONIOENCODING="UTF-8",
LANG="ru_RU.UTF-8",
LC_ALL="ru_RU.UTF-8",
LC_LANG="ru_RU.UTF-8",
SECRET_KEY="*********",
DB_NAME="opentaxi",
DB_USER="postgres",
DB_PASSWORD="*********",
DB_HOST="localhost",
DB_PORT="5432"
command=/root/virtualenvs/opentaxi/bin/python manage.py runworker
directory = /root/www/opentaxi/src
user=root
group=www-data
autorestart=true
stderr_logfile = /root/www/log/opentaxi/workers_errors.log
# =================================================
[program:opentaxi-interface]
environment=DJANGO_SETTINGS_MODULE="settings.base",
PYTHONIOENCODING="UTF-8",
LANG="ru_RU.UTF-8",
LC_ALL="ru_RU.UTF-8",
LC_LANG="ru_RU.UTF-8",
SECRET_KEY="*********",
DB_NAME="opentaxi",
DB_USER="postgres",
DB_PASSWORD="*********",
DB_HOST="localhost",
DB_PORT="5432"
command=/root/virtualenvs/opentaxi/bin/daphne -u /root/www/sockets/daphne.sock settings.asgi:channel_layer
directory = /root/www/opentaxi/src
user=root
group=opentaxi
autorestart=true
stderr_logfile = /root/www/log/opentaxi/interface_errors.log
For future reference:
(google brought me here)
# supervisor.conf
[program:platform_asgi_daphne]
directory=/srv/platform/production/src/
command=/srv/platform/production/env/bin/daphne -u /srv/platform/production/daphne.sock asgi:channel_layer
[program:platform_asgi_workers]
command=/srv/platform/production/env/bin/python /srv/platform/production/src/manage.py runworker
process_name=asgi_worker%(process_num)s
numprocs=4
keep it DRY :)
you can use numprocs for the workers.
Most helpful comment
For future reference:
(google brought me here)
keep it DRY :)
you can use
numprocsfor the workers.