Refactor initialization of on/off schedule
This commit is contained in:
		
							parent
							
								
									5b54f40ec0
								
							
						
					
					
						commit
						a90ea25b87
					
				
					 4 changed files with 47 additions and 58 deletions
				
			
		| 
						 | 
				
			
			@ -27,7 +27,7 @@ async fn create_this_controller(
 | 
			
		|||
		conn,
 | 
			
		||||
		&ControllerUid::default(),
 | 
			
		||||
		&settings.name,
 | 
			
		||||
		i64::try_from(settings.relays.len()).expect("Too many relays"),
 | 
			
		||||
		settings.relays.len() as i64,
 | 
			
		||||
	)
 | 
			
		||||
	.await
 | 
			
		||||
	.expect("Failed to create controller")
 | 
			
		||||
| 
						 | 
				
			
			@ -91,15 +91,15 @@ async fn main() {
 | 
			
		|||
	tokio::spawn(run_relay_loop(settings));
 | 
			
		||||
 | 
			
		||||
	loop {
 | 
			
		||||
		log::info!(
 | 
			
		||||
			"Trying to connect in {} seconds...",
 | 
			
		||||
			WEBSOCKET_RETRY_TIMEOUT.as_secs()
 | 
			
		||||
		);
 | 
			
		||||
		time::sleep(WEBSOCKET_RETRY_TIMEOUT).await;
 | 
			
		||||
 | 
			
		||||
		let connect_result = connect_async(&url).await;
 | 
			
		||||
		if let Err(err) = connect_result {
 | 
			
		||||
			log::warn!(
 | 
			
		||||
				"Failed to connect to websocket: {}. Retrying in {} seconds...",
 | 
			
		||||
				err,
 | 
			
		||||
				WEBSOCKET_RETRY_TIMEOUT.as_secs()
 | 
			
		||||
			);
 | 
			
		||||
			log::warn!("Failed to connect to websocket: {}", err,);
 | 
			
		||||
			continue;
 | 
			
		||||
		}
 | 
			
		||||
		let (ws_stream, _) = connect_result.unwrap();
 | 
			
		||||
| 
						 | 
				
			
			@ -115,10 +115,7 @@ async fn main() {
 | 
			
		|||
 | 
			
		||||
		read_handler.await;
 | 
			
		||||
 | 
			
		||||
		log::warn!(
 | 
			
		||||
			"Lost connection to websocket. Retrying in {} seconds...",
 | 
			
		||||
			WEBSOCKET_RETRY_TIMEOUT.as_secs()
 | 
			
		||||
		);
 | 
			
		||||
		log::warn!("Lost connection to websocket");
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue