File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,10 @@ pub struct Config {
46
46
/// If set, the bridge will check for new Factorio Friday Facts and send them to the chat.
47
47
#[ arg( long, env = "FACTORIO_FRIDAY_FACTS" ) ]
48
48
pub fff : bool ,
49
+
50
+ /// Retry connection if app crashed or server is down
51
+ #[ arg( short = 'r' , long, env) ]
52
+ pub retry : bool ,
49
53
}
50
54
51
55
impl Config {
Original file line number Diff line number Diff line change @@ -8,16 +8,28 @@ use tokio::sync::mpsc;
8
8
use tracing:: { error, info} ;
9
9
10
10
pub async fn run ( tx : mpsc:: Sender < Signal > ) -> Result < ( ) > {
11
+ if CONFIG . retry {
12
+ loop {
13
+ if let Err ( e) = create_reader ( & tx) . await {
14
+ error ! ( "Error reading log file: {}" , e) ;
15
+ }
16
+ }
17
+ }
18
+
19
+ create_reader ( & tx) . await ?;
20
+
21
+ Ok ( ( ) )
22
+ }
23
+
24
+ async fn create_reader ( tx : & mpsc:: Sender < Signal > ) -> Result < ( ) > {
11
25
crate :: log_reader:: read_log ( |line| async {
12
26
if let Some ( ( username, message) ) = parse_log_line ( line) {
13
27
tx. send ( Signal :: MessageFromFactorio { username, message } )
14
28
. await
15
29
. unwrap ( ) ;
16
30
}
17
31
} )
18
- . await ?;
19
-
20
- Ok ( ( ) )
32
+ . await
21
33
}
22
34
23
35
pub async fn send ( message : & str ) {
You can’t perform that action at this time.
0 commit comments