-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_compose.py
More file actions
28 lines (24 loc) · 971 Bytes
/
fix_compose.py
File metadata and controls
28 lines (24 loc) · 971 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env python3
"""Fix docker-compose.yml: add CELERY env vars, remove stray '-' lines."""
path = "/opt/brightclause/docker-compose.yml"
with open(path) as f:
lines = f.readlines()
out = []
for line in lines:
# Skip stray "-" lines left by broken sed
if line.strip() == "-":
continue
out.append(line)
# After each REDIS_URL line (not commented out), add CELERY vars
if "REDIS_URL=redis://redis:6379/0" in line and not line.strip().startswith("#"):
indent = line[:len(line) - len(line.lstrip())]
out.append(f"{indent}- CELERY_BROKER_URL=redis://redis:6379/0\n")
out.append(f"{indent}- CELERY_RESULT_BACKEND=redis://redis:6379/0\n")
with open(path, "w") as f:
f.writelines(out)
# Verify
with open(path) as f:
content = f.read()
print("CELERY_BROKER_URL count:", content.count("CELERY_BROKER_URL"))
print("Stray dash count:", len([l for l in content.split("\n") if l.strip() == "-"]))
print("done")