Skip to content

Commit a14bfdb

Browse files
author
developerworks
committed
Harden dashboard IPC socket path with parent dir creation and demo-friendly defaults
- Ensure parent directory exists before binding dashboard IPC listener - Switch demo config socket paths from /run/rust-supervisor/ to /tmp/rust-supervisor-demo/ - Change bind_mode from create_new to replace_stale for demo resilience
1 parent c54cb43 commit a14bfdb

3 files changed

Lines changed: 18 additions & 6 deletions

File tree

examples/config/supervisor.template.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ observability:
3131
ipc:
3232
enabled: false
3333
target_id: example-target
34-
path: /run/rust-supervisor/example-target.sock
34+
path: /tmp/rust-supervisor-demo/example-target.sock
3535
permissions: "0600"
36-
bind_mode: create_new
36+
bind_mode: replace_stale
3737
registration:
3838
enabled: false
39-
relay_registration_path: /run/rust-supervisor/dashboard-relay-registration.sock
39+
relay_registration_path: /tmp/rust-supervisor-demo/dashboard-relay-registration.sock
4040
display_name: "example target"
4141
lease_seconds: 30
4242
registration_heartbeat_interval_seconds: 15

examples/config/supervisor.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ observability:
2020
ipc:
2121
enabled: true
2222
target_id: payments-worker-a
23-
path: /run/rust-supervisor/payments-worker-a.sock
23+
path: /tmp/rust-supervisor-demo/payments-worker-a.sock
2424
permissions: "0600"
25-
bind_mode: create_new
25+
bind_mode: replace_stale
2626
registration:
2727
enabled: true
28-
relay_registration_path: /run/rust-supervisor/dashboard-relay-registration.sock
28+
relay_registration_path: /tmp/rust-supervisor-demo/dashboard-relay-registration.sock
2929
display_name: "payments worker a"
3030
lease_seconds: 30
3131
registration_heartbeat_interval_seconds: 15

src/dashboard/ipc_server.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,18 @@ pub fn bind_dashboard_listener(
465465
config: &ValidatedDashboardIpcConfig,
466466
) -> Result<UnixListener, DashboardError> {
467467
prepare_socket_path(config)?;
468+
// Ensure the parent directory exists before binding.
469+
if let Some(parent) = config.path.parent() {
470+
std::fs::create_dir_all(parent).map_err(|error| {
471+
DashboardError::new(
472+
"ipc_parent_dir_creation_failed",
473+
"ipc_bind",
474+
Some(config.target_id.clone()),
475+
format!("failed to create IPC parent directory: {error}"),
476+
false,
477+
)
478+
})?;
479+
}
468480
UnixListener::bind(&config.path).map_err(|error| {
469481
DashboardError::new(
470482
"ipc_bind_failed",

0 commit comments

Comments
 (0)