提交 19a9d57d authored 作者: Serhij S's avatar Serhij S

0.1.44

上级 45daf83d
[package] [package]
name = "roboplc" name = "roboplc"
version = "0.1.43" version = "0.1.44"
edition = "2021" edition = "2021"
authors = ["Serhij S. <div@altertech.com>"] authors = ["Serhij S. <div@altertech.com>"]
license = "Apache-2.0" license = "Apache-2.0"
......
...@@ -8,6 +8,7 @@ use std::{ ...@@ -8,6 +8,7 @@ use std::{
}; };
use crate::{ use crate::{
critical,
hub::Hub, hub::Hub,
suicide, suicide,
supervisor::Supervisor, supervisor::Supervisor,
...@@ -156,6 +157,11 @@ where ...@@ -156,6 +157,11 @@ where
self.supervisor.spawn(builder, move || { self.supervisor.spawn(builder, move || {
if let Err(e) = worker.run(&context) { if let Err(e) = worker.run(&context) {
error!(worker=worker.worker_name(), error=%e, "worker terminated"); error!(worker=worker.worker_name(), error=%e, "worker terminated");
critical(&format!(
"Worker {} terminated: {}",
worker.worker_name(),
e
));
} }
})?; })?;
Ok(()) Ok(())
...@@ -349,7 +355,8 @@ where ...@@ -349,7 +355,8 @@ where
pub trait Worker<D: DataDeliveryPolicy + Clone + Send + Sync + 'static, V: Send>: pub trait Worker<D: DataDeliveryPolicy + Clone + Send + Sync + 'static, V: Send>:
Send + Sync Send + Sync
{ {
/// The worker's main function, started by [`Controller::spawn_worker()`] /// The worker's main function, started by [`Controller::spawn_worker()`]. If the function
/// returns an error, the process is terminated using [`critical()`].
fn run(&mut self, context: &Context<D, V>) -> WResult; fn run(&mut self, context: &Context<D, V>) -> WResult;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论