File tree Expand file tree Collapse file tree 1 file changed +13
-11
lines changed Expand file tree Collapse file tree 1 file changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -23,20 +23,22 @@ impl Cron {
23
23
async fn start_cron ( & self ) {
24
24
loop {
25
25
sleep ( Duration :: from_millis ( self . sleep_time ) ) . await ;
26
- self . execute_command ( ) . await ;
26
+ self . execute_command ( ) ;
27
27
}
28
28
}
29
29
30
- async fn execute_command ( & self ) {
31
- print ! ( "CRON::{} =>" , self . name) ;
32
- let _ = Command :: new ( "sh" )
33
- . arg ( "-c" )
34
- . arg ( self . command . clone ( ) )
35
- . stdout ( Stdio :: inherit ( ) )
36
- . status ( )
37
- . await ;
38
- println ! ( "end" ) ;
39
-
30
+ fn execute_command ( & self ) {
31
+ println ! ( "{} => " , self . name) ;
32
+ let x = |command : String | {
33
+ tokio:: spawn ( async move {
34
+ let _ = Command :: new ( "sh" )
35
+ . arg ( "-c" )
36
+ . arg ( command. clone ( ) )
37
+ . stdout ( Stdio :: inherit ( ) )
38
+ . status ( ) . await ;
39
+ } ) ;
40
+ } ;
41
+ x ( self . command . clone ( ) ) ;
40
42
}
41
43
}
42
44
You can’t perform that action at this time.
0 commit comments