Script for running Daphne and runworker in the background . runworker ends after session expires.

227 views
Skip to first unread message

Adam Zedan

unread,
Mar 23, 2019, 10:51:26 PM3/23/19
to Django users
I am trying to create a bash script that would run Daphne and runworker in the background.
This is what I came up with so far


echo
"Killing Redis....."
killall redis
-server


#echo "Starting redis Server....."
redis
-server --daemonize yes


echo
"Stopping NGINX......"
sudo
/etc/init.d/nginx stop


echo
"Starting NGINX......"
sudo
/etc/init.d/nginx start


echo
"Killing Daphne......"
sudo kill
-9 $(ps aux | grep 'daphne' | awk '{print $2}')


echo
"Starting Daphne....."
/home/ec2-user/MyDomainVenv/bin/daphne -b 0.0.0.0 -p 8001 main.asgi:channel_layer 2>> ./daphne.log &


echo
"Starting Django worker thread...."
#nohup python ./manage.py runworker 2>>./daphneWorker.log >&2 &
python
./manage.py runworker


However it seems like run worker simply terminates when my ssh session expires. I tried nohup statement as well.
How did you fix this problem ?

Adam Zedan

unread,
Mar 23, 2019, 10:53:50 PM3/23/19
to Django users
Seems like Daphne and runworker both terminate after session expires

Aldian Fazrihady

unread,
Mar 23, 2019, 11:36:06 PM3/23/19
to django...@googlegroups.com
Hi,
Mine is like this. It is still running after exiting ssh:
nohup daphne -v 2 -b $AFCOM_DAPHNE_HOST -p $AFCOM_DAPHNE_PORT afcom.asgi:application > $AFCOM_PROJECT_PATH/daphne/afcom.log 2>&1 &

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b2a43f85-9b9a-48bf-918d-c70a70b1b80b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Adam Zedan

unread,
Mar 23, 2019, 11:42:01 PM3/23/19
to django...@googlegroups.com
Thanks Aldian , what about runworker ?

You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/chqoK7I_v4A/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

Aldian Fazrihady

unread,
Mar 23, 2019, 11:49:10 PM3/23/19
to django...@googlegroups.com
On Sun, Mar 24, 2019 at 11:41 AM Adam Zedan <zeda...@gmail.com> wrote:
Thanks Aldian , what about runworker ?

I don't use Daphne worker. However, I am using celery  
Reply all
Reply to author
Forward
0 new messages