@@ -57,51 +57,54 @@ impl PoolSv2 {
57
57
58
58
// Start the error handling loop
59
59
// See `./status.rs` and `utils/error_handling` for information on how this operates
60
- loop {
61
- let task_status = select ! {
62
- task_status = status_rx. recv( ) => task_status,
63
- interrupt_signal = tokio:: signal:: ctrl_c( ) => {
64
- match interrupt_signal {
65
- Ok ( ( ) ) => {
66
- info!( "Interrupt received" ) ;
67
- } ,
68
- Err ( err) => {
69
- error!( "Unable to listen for interrupt signal: {}" , err) ;
70
- // we also shut down in case of error
71
- } ,
60
+ tokio:: spawn ( async move {
61
+ loop {
62
+ let task_status = select ! {
63
+ task_status = status_rx. recv( ) => task_status,
64
+ interrupt_signal = tokio:: signal:: ctrl_c( ) => {
65
+ match interrupt_signal {
66
+ Ok ( ( ) ) => {
67
+ info!( "Interrupt received" ) ;
68
+ } ,
69
+ Err ( err) => {
70
+ error!( "Unable to listen for interrupt signal: {}" , err) ;
71
+ // we also shut down in case of error
72
+ } ,
73
+ }
74
+ break ;
72
75
}
73
- break Ok ( ( ) ) ;
74
- }
75
- } ;
76
- let task_status: status:: Status = task_status. unwrap ( ) ;
76
+ } ;
77
+ let task_status: status:: Status = task_status. unwrap ( ) ;
77
78
78
- match task_status. state {
79
- // Should only be sent by the downstream listener
80
- status:: State :: DownstreamShutdown ( err) => {
81
- error ! (
82
- "SHUTDOWN from Downstream: {}\n Try to restart the downstream listener" ,
83
- err
84
- ) ;
85
- break Ok ( ( ) ) ;
86
- }
87
- status:: State :: TemplateProviderShutdown ( err) => {
88
- error ! ( "SHUTDOWN from Upstream: {}\n Try to reconnecting or connecting to a new upstream" , err) ;
89
- break Ok ( ( ) ) ;
90
- }
91
- status:: State :: Healthy ( msg) => {
92
- info ! ( "HEALTHY message: {}" , msg) ;
93
- }
94
- status:: State :: DownstreamInstanceDropped ( downstream_id) => {
95
- warn ! ( "Dropping downstream instance {} from pool" , downstream_id) ;
96
- if pool
97
- . safe_lock ( |p| p. remove_downstream ( downstream_id) )
98
- . is_err ( )
99
- {
100
- break Ok ( ( ) ) ;
79
+ match task_status. state {
80
+ // Should only be sent by the downstream listener
81
+ status:: State :: DownstreamShutdown ( err) => {
82
+ error ! (
83
+ "SHUTDOWN from Downstream: {}\n Try to restart the downstream listener" ,
84
+ err
85
+ ) ;
86
+ break ;
87
+ }
88
+ status:: State :: TemplateProviderShutdown ( err) => {
89
+ error ! ( "SHUTDOWN from Upstream: {}\n Try to reconnecting or connecting to a new upstream" , err) ;
90
+ break ;
91
+ }
92
+ status:: State :: Healthy ( msg) => {
93
+ info ! ( "HEALTHY message: {}" , msg) ;
94
+ }
95
+ status:: State :: DownstreamInstanceDropped ( downstream_id) => {
96
+ warn ! ( "Dropping downstream instance {} from pool" , downstream_id) ;
97
+ if pool
98
+ . safe_lock ( |p| p. remove_downstream ( downstream_id) )
99
+ . is_err ( )
100
+ {
101
+ break ;
102
+ }
101
103
}
102
104
}
103
105
}
104
- }
106
+ } ) ;
107
+ Ok ( ( ) )
105
108
}
106
109
}
107
110
0 commit comments