Skip to content

Commit 553d15a

Browse files
committed
Get socket path from /opt/dsf/conf/config.json
1 parent a29b854 commit 553d15a

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/dsf/__init__.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
11
__version__ = "3.6.0-rc1.post1"
22

3-
# path to unix socket file
3+
import json
4+
import os
5+
6+
# Default socket file path
47
SOCKET_FILE = "/run/dsf/dcs.sock"
58

9+
# Try to read socket file path from config
10+
config_path = "/opt/dsf/conf/config.json"
11+
if os.path.exists(config_path):
12+
try:
13+
with open(config_path, 'r') as f:
14+
config = json.load(f)
15+
socket_dir = config.get("SocketDirectory", "/run/dsf")
16+
socket_file = config.get("SocketFile", "dcs.sock")
17+
SOCKET_FILE = os.path.join(socket_dir, socket_file)
18+
except (json.JSONDecodeError, IOError):
19+
pass # Use default if config file is invalid or inaccessible
20+
621
# allowed connection per unix server
722
DEFAULT_BACKLOG = 4
823

0 commit comments

Comments
 (0)