Skip to content

Commit

Permalink
Merge pull request #79 from AndrewKvalheim/redis-url
Browse files Browse the repository at this point in the history
Configure Redis connection via URL instead of TCP host and port
  • Loading branch information
artiommocrenco authored Nov 24, 2024
2 parents 3a75985 + 334a0cb commit a76a0b1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
3 changes: 1 addition & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ MQTT_KEEPALIVE=15
MQTT_USERNAME=
MQTT_PASSWORD=
MQTT_TOPIC='msh/#'
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_URL='redis://localhost:6379'
PROMETHEUS_ENDPOINT='http://grafana/api/v1/push'
PROMETHEUS_TOKEN='changeme'
3 changes: 1 addition & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ services:
# - MQTT_USERNAME=changeme
# - MQTT_PASSWORD=changeme
- MQTT_TOPIC=msh/EU_433/#
- REDIS_HOST=redis
- REDIS_PORT=6379
- REDIS_URL=redis://redis:6379
networks:
- mesh-bridge
# Redis is being utilised for storing persistent state
Expand Down
7 changes: 2 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@
"prometheus_token": os.environ.get("PROMETHEUS_TOKEN"),
"prometheus_server_addr": os.environ.get("PROMETHEUS_SERVER_ADDR", "0.0.0.0"),
"prometheus_server_port": os.environ.get("PROMETHEUS_SERVER_PORT", 9464),
"redis_host": os.environ.get("REDIS_HOST", "localhost"),
"redis_port": os.environ.get("REDIS_PORT", 6379),
"redis_url": os.environ.get("REDIS_URL", "redis://localhost:6379"),
"log_level": os.environ.get("LOG_LEVEL", "INFO"),
"flood_expire_time": os.environ.get("FLOOD_EXPIRE_TIME", 10 * 60),
}
Expand All @@ -69,9 +68,7 @@

logger.addHandler(handler)

redis = redis.Redis(
host=config["redis_host"], port=config["redis_port"], db=0, protocol=3
)
redis = redis.from_url(config["redis_url"], db=0, protocol=3)

headers = {}
if config["prometheus_token"]:
Expand Down

0 comments on commit a76a0b1

Please sign in to comment.