Skip to content

Commit 8163f10

Browse files
committed
fix: Obey Boblight server enable flag
1 parent fb445d9 commit 8163f10

File tree

1 file changed

+26
-13
lines changed

1 file changed

+26
-13
lines changed

src/instance.rs

+26-13
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub struct Instance {
4242
local_receiver: mpsc::Receiver<InputMessage>,
4343
muxer: PriorityMuxer,
4444
core: Core,
45-
_boblight_server: Result<ServerHandle, std::io::Error>,
45+
_boblight_server: Option<Result<ServerHandle, std::io::Error>>,
4646
}
4747

4848
impl Instance {
@@ -66,18 +66,31 @@ impl Instance {
6666
let core = Core::new(&config).await;
6767

6868
let config = Arc::new(config);
69-
let _boblight_server = servers::bind(
70-
"Boblight",
71-
config.boblight_server.clone(),
72-
global.clone(),
73-
{
74-
let instance = config.clone();
75-
move |tcp, global| {
76-
servers::boblight::handle_client(tcp, tx.clone(), instance.clone(), global)
77-
}
78-
},
79-
)
80-
.await;
69+
let _boblight_server = if config.boblight_server.enable {
70+
let server_handle = servers::bind(
71+
"Boblight",
72+
config.boblight_server.clone(),
73+
global.clone(),
74+
{
75+
let instance = config.clone();
76+
move |tcp, global| {
77+
servers::boblight::handle_client(tcp, tx.clone(), instance.clone(), global)
78+
}
79+
},
80+
)
81+
.await;
82+
83+
if let Err(error) = &server_handle {
84+
error!(
85+
"Cannot start Boblight server for instance {} `{}` failed: {}",
86+
config.instance.id, config.instance.friendly_name, error
87+
);
88+
}
89+
90+
Some(server_handle)
91+
} else {
92+
None
93+
};
8194

8295
Self {
8396
device,

0 commit comments

Comments
 (0)