Skip to content

Commit

Permalink
Set socket_keepalive = True for all Redis connections (#705)
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Berendt <berendt@osism.tech>
  • Loading branch information
berendt committed Nov 29, 2023
1 parent b00917e commit 8bc0eed
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 8 deletions.
5 changes: 4 additions & 1 deletion osism/commands/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ def take_action(self, parsed_args):
p.wait()

elif service == "flower":
p = subprocess.Popen("celery --broker=redis://redis flower", shell=True)
p = subprocess.Popen(
"celery --broker=redis://redis flower",
shell=True,
)
p.wait()

elif service == "reconciler":
Expand Down
1 change: 1 addition & 0 deletions osism/commands/wait.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def take_action(self, parsed_args):
host=settings.REDIS_HOST,
port=settings.REDIS_PORT,
db=settings.REDIS_DB,
socket_keepalive=True,
)
redis.ping()

Expand Down
10 changes: 8 additions & 2 deletions osism/tasks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ def celery_init_worker(**kwargs):
global redis

redis = Redis(
host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=settings.REDIS_DB
host=settings.REDIS_HOST,
port=settings.REDIS_PORT,
db=settings.REDIS_DB,
socket_keepalive=True,
)
redis.ping()

Expand Down Expand Up @@ -230,7 +233,10 @@ def handle_task(t, wait, format, timeout):

if not redis:
redis = Redis(
host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=settings.REDIS_DB
host=settings.REDIS_HOST,
port=settings.REDIS_PORT,
db=settings.REDIS_DB,
socket_keepalive=True,
)
redis.ping()

Expand Down
5 changes: 4 additions & 1 deletion osism/tasks/conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ def celery_init_worker(**kwargs):
global redis

redis = Redis(
host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=settings.REDIS_DB
host=settings.REDIS_HOST,
port=settings.REDIS_PORT,
db=settings.REDIS_DB,
socket_keepalive=True,
)
redis.ping()

Expand Down
5 changes: 4 additions & 1 deletion osism/tasks/netbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ def celery_init_worker(**kwargs):
global redis

redis = Redis(
host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=settings.REDIS_DB
host=settings.REDIS_HOST,
port=settings.REDIS_PORT,
db=settings.REDIS_DB,
socket_keepalive=True,
)
redis.ping()

Expand Down
5 changes: 4 additions & 1 deletion osism/tasks/openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ def celery_init_worker(**kwargs):
global redis

redis = Redis(
host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=settings.REDIS_DB
host=settings.REDIS_HOST,
port=settings.REDIS_PORT,
db=settings.REDIS_DB,
socket_keepalive=True,
)
redis.ping()

Expand Down
5 changes: 4 additions & 1 deletion osism/tasks/reconciler.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ def celery_init_worker(**kwargs):
global redis

redis = Redis(
host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=settings.REDIS_DB
host=settings.REDIS_HOST,
port=settings.REDIS_PORT,
db=settings.REDIS_DB,
socket_keepalive=True,
)
redis.ping()

Expand Down
7 changes: 6 additions & 1 deletion osism/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
from redis import Redis
import urllib3

redis = Redis(host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=settings.REDIS_DB)
redis = Redis(
host=settings.REDIS_HOST,
port=settings.REDIS_PORT,
db=settings.REDIS_DB,
socket_keepalive=True,
)
redis.ping()

if settings.NETBOX_URL and settings.NETBOX_TOKEN:
Expand Down

0 comments on commit 8bc0eed

Please sign in to comment.