change redis port to 6579 when DOCKERBUILD is an env variable

This commit is contained in:
Jonathan Math 2020-10-24 19:43:17 +07:00
parent 5877fd979e
commit 54dfbe9c41
6 changed files with 39 additions and 38 deletions

View file

@ -65,7 +65,7 @@ services:
redis:
image: redis:3
ports:
- '6379:6379'
- '6579:6579'
container_name: redis
volumes:
- ./docker/volumes/redis:/data

View file

@ -33,7 +33,7 @@ ENFORCE_SIGNUP_CAPTCHA = False
CACHES = {
'default': {
'BACKEND': 'redis_cache.RedisCache',
'LOCATION': 'redis:6379',
'LOCATION': 'redis:6579',
'OPTIONS': {
'DB': 6,
'PARSER_CLASS': 'redis.connection.HiredisParser'
@ -99,7 +99,7 @@ MONGODB_SLAVE = {
}
# Celery RabbitMQ/Redis Broker
BROKER_URL = "redis://redis:6379/0"
BROKER_URL = "redis://redis:6579/0"
CELERY_RESULT_BACKEND = BROKER_URL
REDIS = {
@ -113,7 +113,7 @@ REDIS_STORY = {
}
REDIS_SESSIONS = {
'host': 'redis',
'port': 6379
'port': 6579
}
CELERY_REDIS_DB_NUM = 4

View file

@ -578,8 +578,10 @@ S3_AVATARS_BUCKET_NAME = 'avatars.newsblur.com'
# ==================
if os.getenv("DOCKERBUILD"):
from newsblur_web.docker_local_settings import *
REDIS_PORT = 6579
else:
from newsblur_web.local_settings import *
REDIS_PORT = 6379
if not DEBUG:
INSTALLED_APPS += (
@ -680,12 +682,14 @@ MONGOANALYTICSDB = connect(MONGO_ANALYTICS_DB_NAME, **MONGO_ANALYTICS_DB)
# = Redis =
# =========
CELERY_BROKER_URL = "redis://%s:6379/%s" % (REDIS['host'], CELERY_REDIS_DB_NUM)
CELERY_REDIS_DB_NUM = 4
SESSION_REDIS_DB = 5
CELERY_BROKER_URL = "redis://%s:%s/%s" % (REDIS['host'], REDIS_PORT,CELERY_REDIS_DB_NUM)
CELERY_RESULT_BACKEND = CELERY_BROKER_URL
SESSION_REDIS = {
'host': REDIS_SESSIONS['host'],
'port': 6379,
'port': REDIS_PORT,
'db': SESSION_REDIS_DB,
# 'password': 'password',
'prefix': '',
@ -696,7 +700,7 @@ SESSION_REDIS = {
CACHES = {
'default': {
'BACKEND': 'redis_cache.RedisCache',
'LOCATION': '%s:6379' % REDIS['host'],
'LOCATION': '%s:%s' % REDIS['host'], REDIS_PORT,
'OPTIONS': {
'DB': 6,
'PARSER_CLASS': 'redis.connection.HiredisParser',
@ -705,18 +709,18 @@ CACHES = {
},
}
REDIS_POOL = redis.ConnectionPool(host=REDIS['host'], port=6379, db=0, decode_responses=True)
REDIS_ANALYTICS_POOL = redis.ConnectionPool(host=REDIS['host'], port=6379, db=2, decode_responses=True)
REDIS_STATISTICS_POOL = redis.ConnectionPool(host=REDIS['host'], port=6379, db=3, decode_responses=True)
REDIS_FEED_UPDATE_POOL = redis.ConnectionPool(host=REDIS['host'], port=6379, db=4, decode_responses=True)
# REDIS_STORY_HASH_POOL2 = redis.ConnectionPool(host=REDIS['host'], port=6379, db=8) # Only used when changing DAYS_OF_UNREAD
REDIS_STORY_HASH_TEMP_POOL = redis.ConnectionPool(host=REDIS['host'], port=6379, db=10, decode_responses=True)
# REDIS_CACHE_POOL = redis.ConnectionPool(host=REDIS['host'], port=6379, db=6) # Duped in CACHES
REDIS_STORY_HASH_POOL = redis.ConnectionPool(host=REDIS_STORY['host'], port=6379, db=1, decode_responses=True)
REDIS_FEED_READ_POOL = redis.ConnectionPool(host=REDIS_SESSIONS['host'], port=6379, db=1, decode_responses=True)
REDIS_FEED_SUB_POOL = redis.ConnectionPool(host=REDIS_SESSIONS['host'], port=6379, db=2, decode_responses=True)
REDIS_SESSION_POOL = redis.ConnectionPool(host=REDIS_SESSIONS['host'], port=6379, db=5, decode_responses=True)
REDIS_PUBSUB_POOL = redis.ConnectionPool(host=REDIS_PUBSUB['host'], port=6379, db=0, decode_responses=True)
REDIS_POOL = redis.ConnectionPool(host=REDIS['host'], port=REDIS_PORT, db=0, decode_responses=True)
REDIS_ANALYTICS_POOL = redis.ConnectionPool(host=REDIS['host'], port=REDIS_PORT, db=2, decode_responses=True)
REDIS_STATISTICS_POOL = redis.ConnectionPool(host=REDIS['host'], port=REDIS_PORT, db=3, decode_responses=True)
REDIS_FEED_UPDATE_POOL = redis.ConnectionPool(host=REDIS['host'], port=REDIS_PORT, db=4, decode_responses=True)
# REDIS_STORY_HASH_POOL2 = redis.ConnectionPool(host=REDIS['host'], port=REDIS_PORT, db=8) # Only used when changing DAYS_OF_UNREAD
REDIS_STORY_HASH_TEMP_POOL = redis.ConnectionPool(host=REDIS['host'], port=REDIS_PORT, db=10, decode_responses=True)
# REDIS_CACHE_POOL = redis.ConnectionPool(host=REDIS['host'], port=REDIS_PORT, db=6) # Duped in CACHES
REDIS_STORY_HASH_POOL = redis.ConnectionPool(host=REDIS_STORY['host'], port=REDIS_PORT, db=1, decode_responses=True)
REDIS_FEED_READ_POOL = redis.ConnectionPool(host=REDIS_SESSIONS['host'], port=REDIS_PORT, db=1, decode_responses=True)
REDIS_FEED_SUB_POOL = redis.ConnectionPool(host=REDIS_SESSIONS['host'], port=REDIS_PORT, db=2, decode_responses=True)
REDIS_SESSION_POOL = redis.ConnectionPool(host=REDIS_SESSIONS['host'], port=REDIS_PORT, db=5, decode_responses=True)
REDIS_PUBSUB_POOL = redis.ConnectionPool(host=REDIS_PUBSUB['host'], port=REDIS_PORT, db=0, decode_responses=True)
# ==========
# = Celery =

View file

@ -1,11 +1,11 @@
import sys
from newsblur_web.settings import *
import os
# if 'test' in sys.argv:
# DATABASES['default']['ENGINE'] = 'django.db.backends.sqlite3'
# DATABASES['default']['OPTIONS'] = {}
# # DATABASES['default']['NAME'] = 'nb.db'
# # DATABASES['default']['TEST_NAME'] = 'nb2.db'
if 'test' in sys.argv:
DATABASES['default']['ENGINE'] = 'django.db.backends.sqlite3'
DATABASES['default']['OPTIONS'] = {}
DATABASES['default']['NAME'] = 'nb.db'
DATABASES['default']['TEST_NAME'] = 'nb2.db'
# DATABASES = {
# 'default':{
@ -14,17 +14,10 @@ import os
# 'TEST_NAME': ':memory:',
# },
# }
if os.getenv("DOCKERBUILD"):
MONGO_DB = {
'name': 'newsblur_test',
'host': 'db_mongo:27017'
}
else:
MONGO_DB = {
'name': 'newsblur_test',
'host': '127.0.0.1:27017',
}
MONGO_DB = {
'name': 'newsblur_test',
'host': '127.0.0.1:27017',
}
MONGO_DATABASE_NAME = 'test_newsblur'
# TEST_DATABASE_NAME = ":memory:"
@ -35,6 +28,7 @@ TEST_DEBUG = True
DEBUG = True
SITE_ID = 2
RAVEN_CLIENT = None
HOMEPAGE_USERNAME = 'conesus'
# from django.db import connection
# cursor = connection.cursor()
# cursor.execute('PRAGMA temp_store = MEMORY;')

View file

@ -5,6 +5,7 @@ log = require './log.js'
DEV = process.env.NODE_ENV == 'development'
DOCKER = process.env.NODE_ENV == 'docker'
REDIS_SERVER = if process.env.NODE_ENV == 'development' then 'localhost' else if DOCKER then 'redis' else 'db_redis_pubsub'
REDIS_PORT = process.env.env.NODE_ENV == 'docker' then 6579 else 6379
SECURE = !!process.env.NODE_SSL
# client = redis.createClient 6379, REDIS_SERVER
@ -65,7 +66,7 @@ io.on 'connection', (socket) ->
socket.on "error", (err) ->
log.debug "Error (socket): #{err}"
socket.subscribe?.quit()
socket.subscribe = redis.createClient 6379, REDIS_SERVER
socket.subscribe = redis.createClient REDIS_PORT, REDIS_SERVER
socket.subscribe.on "error", (err) =>
log.info @username, "Error: #{err} (#{@feeds.length} feeds)"
socket.subscribe?.quit()

View file

@ -14,6 +14,8 @@
REDIS_SERVER = process.env.NODE_ENV === 'development' ? 'localhost' : DOCKER ? 'redis' : 'db_redis_pubsub';
REDIS_PORT = process.env.NODE_ENV === 'docker' ? 6379 : 6579;
SECURE = !!process.env.NODE_SSL;
log.debug("Starting NewsBlur unread count server...");
@ -70,7 +72,7 @@
if ((_ref = socket.subscribe) != null) {
_ref.quit();
}
socket.subscribe = redis.createClient(6379, REDIS_SERVER);
socket.subscribe = redis.createClient(REDIS_PORT, REDIS_SERVER);
socket.subscribe.on("error", (function(_this) {
return function(err) {
var _ref1;