Re: [django-channels] Running multiple daphne servers

2018-02-19 Thread Tomáš Ehrlich
Ah, problem solved.

This line forces db=0 in asgi_redis 1.x:
https://github.com/django/channels_redis/blob/1.x/asgi_redis/core.py#L566 


in 2.x version it seems to be fixed.

Thanks again! :)

> 19. 2. 2018 v 21:02, Tomáš Ehrlich :
> 
> You’re absolutely right, using different prefix solves the problem. 
> asgi_redis seems to be ignoring
> my connection_kwargs where I set the db.
> 
> Connection_kwargs should be set like this, right?
> 
> REDIS = {
> "hosts": [(os.environ.get('REDIS_HOST'), 6379)],
> "connection_kwargs": {
> "db": os.environ.get('REDIS_DB'),
> }
> }
> 
> CHANNEL_LAYERS = {
> "default": {
> "BACKEND": "asgi_redis.RedisChannelLayer",
> "ROUTING": "birdview_api.channels.routing.channel_routing",
> "CONFIG": REDIS,
> },
> }
> 
> I double checked the env vars and also source code of asgi_redis, but still 
> no luck.
> 
> Anyway, this question was already aswered. Different isntances need to have 
> different prefix or db.
> 
> 
> Thank you Andrew! going to update to channels 2.x soon
> 
> Cheers,
>Tom
> 
>> 19. 2. 2018 v 19:10, Andrew Godwin > >:
>> 
>> Presuming you are using Channels/Daphne 1, then the channel layer 
>> configuration is what determines what handles the requests.
>> 
>> If you're seeing environments answer each other's requests, check they 
>> really are using different Redis databases, and consider changing the prefix 
>> setting on the channel layer instead.
>> 
>> Andrew
>> 
>> On Mon, Feb 19, 2018 at 8:34 AM, Tomáš Ehrlich > >wrote:
>> Hello everyone,
>> I'm running two instances of Daphne on my server (one per environment, 
>> production/staging).
>> I'm using UNIX sockets behind nginx, but production requests are sent to 
>> staging and vice versa.
>> 
>> Workers and Daphne are using the same settings per environment (I'm using 
>> Redis as a channel
>> layer and each environment uses it's own DB), but how Daphne actually knows 
>> which workers
>> belongs to her?
>> 
>> 
>> Thank you in advance
>> 
>> 
>> Cheers,
>>Tom
>> 
>> --
>> 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+unsubscr...@googlegroups.com 
>> .
>> To post to this group, send email to django-users@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/66fabb88-4350-4275-8d4e-25f30e4e3b00%40googlegroups.com
>>  
>> .
>> For more options, visit https://groups.google.com/d/optout 
>> .
>> 
>> 
>> --
>> 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/wfxiPfqUPnk/unsubscribe 
>> .
>> To unsubscribe from this group and all its topics, send an email to 
>> django-users+unsubscr...@googlegroups.com 
>> .
>> To post to this group, send email to django-users@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/CAFwN1urrLN7xVc3EM0-7rEeB2DyLo21JmB9bRiYQioYKq6bEfA%40mail.gmail.com
>>  
>> .
>> For more options, visit https://groups.google.com/d/optout 
>> .
> 

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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/736810F0-AA38-499C-B371-E9C818B43B68%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: Message signed with OpenPGP


Re: [django-channels] Running multiple daphne servers

2018-02-19 Thread Tomáš Ehrlich
You’re absolutely right, using different prefix solves the problem. asgi_redis 
seems to be ignoring
my connection_kwargs where I set the db.

Connection_kwargs should be set like this, right?

REDIS = {
"hosts": [(os.environ.get('REDIS_HOST'), 6379)],
"connection_kwargs": {
"db": os.environ.get('REDIS_DB'),
}
}

CHANNEL_LAYERS = {
"default": {
"BACKEND": "asgi_redis.RedisChannelLayer",
"ROUTING": "birdview_api.channels.routing.channel_routing",
"CONFIG": REDIS,
},
}

I double checked the env vars and also source code of asgi_redis, but still no 
luck.

Anyway, this question was already aswered. Different isntances need to have 
different prefix or db.


Thank you Andrew! going to update to channels 2.x soon

Cheers,
   Tom

> 19. 2. 2018 v 19:10, Andrew Godwin :
> 
> Presuming you are using Channels/Daphne 1, then the channel layer 
> configuration is what determines what handles the requests.
> 
> If you're seeing environments answer each other's requests, check they really 
> are using different Redis databases, and consider changing the prefix setting 
> on the channel layer instead.
> 
> Andrew
> 
> On Mon, Feb 19, 2018 at 8:34 AM, Tomáš Ehrlich  >wrote:
> Hello everyone,
> I'm running two instances of Daphne on my server (one per environment, 
> production/staging).
> I'm using UNIX sockets behind nginx, but production requests are sent to 
> staging and vice versa.
> 
> Workers and Daphne are using the same settings per environment (I'm using 
> Redis as a channel
> layer and each environment uses it's own DB), but how Daphne actually knows 
> which workers
> belongs to her?
> 
> 
> Thank you in advance
> 
> 
> Cheers,
>Tom
> 
> --
> 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+unsubscr...@googlegroups.com 
> .
> To post to this group, send email to django-users@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/66fabb88-4350-4275-8d4e-25f30e4e3b00%40googlegroups.com
>  
> .
> For more options, visit https://groups.google.com/d/optout 
> .
> 
> 
> --
> 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/wfxiPfqUPnk/unsubscribe 
> .
> To unsubscribe from this group and all its topics, send an email to 
> django-users+unsubscr...@googlegroups.com 
> .
> To post to this group, send email to django-users@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/CAFwN1urrLN7xVc3EM0-7rEeB2DyLo21JmB9bRiYQioYKq6bEfA%40mail.gmail.com
>  
> .
> For more options, visit https://groups.google.com/d/optout 
> .

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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/8767E794-BAD3-4CF3-84CA-29A04BC6EC6A%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: Message signed with OpenPGP


Re: [django-channels] Running multiple daphne servers

2018-02-19 Thread Andrew Godwin
Presuming you are using Channels/Daphne 1, then the channel layer
configuration is what determines what handles the requests.

If you're seeing environments answer each other's requests, check they
really are using different Redis databases, and consider changing the
prefix setting on the channel layer instead.

Andrew

On Mon, Feb 19, 2018 at 8:34 AM, Tomáš Ehrlich 
wrote:

> Hello everyone,
> I'm running two instances of Daphne on my server (one per environment,
> production/staging).
> I'm using UNIX sockets behind nginx, but production requests are sent to
> staging and vice versa.
>
> Workers and Daphne are using the same settings per environment (I'm using
> Redis as a channel
> layer and each environment uses it's own DB), but how Daphne actually
> knows which workers
> belongs to her?
>
>
> Thank you in advance
>
>
> Cheers,
>Tom
>
> --
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@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/66fabb88-4350-4275-8d4e-25f30e4e3b00%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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/CAFwN1urrLN7xVc3EM0-7rEeB2DyLo21JmB9bRiYQioYKq6bEfA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.