MyService/
MyService.rs

1use rs_svc::svc::service::Service;
2
3struct MyService;
4
5impl Service for MyService {
6    fn init(&self) -> anyhow::Result<()> {
7        println!("init");
8        Ok(())
9    }
10
11    // must be non-blocking
12    fn start(&self) -> anyhow::Result<()> {
13        std::thread::spawn(move || {
14            println!("start")
15        });
16        Ok(())
17    }
18
19    fn stop(&self) -> anyhow::Result<()> {
20        print!("stop");
21        Ok(())
22    }
23}
24
25
26fn main() {
27    let my_svc = MyService;
28    rs_svc::svc::service::run(&my_svc).unwrap()
29}