1
1
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
// SPDX-License-Identifier: Apache-2.0
3
3
4
+ mod readiness;
5
+
4
6
use http:: {
5
7
header:: { HeaderName , HeaderValue } ,
6
8
Method , StatusCode ,
@@ -13,6 +15,7 @@ use lambda_http::request::RequestContext;
13
15
use lambda_http:: Body ;
14
16
pub use lambda_http:: Error ;
15
17
use lambda_http:: { Request , RequestExt , Response } ;
18
+ use readiness:: Checkpoint ;
16
19
use std:: fmt:: Debug ;
17
20
use std:: {
18
21
env,
@@ -24,8 +27,7 @@ use std::{
24
27
} ,
25
28
time:: Duration ,
26
29
} ;
27
- use tokio:: net:: TcpStream ;
28
- use tokio:: time:: timeout;
30
+ use tokio:: { net:: TcpStream , time:: timeout} ;
29
31
use tokio_retry:: { strategy:: FixedInterval , Retry } ;
30
32
use tower:: { Service , ServiceBuilder } ;
31
33
use tower_http:: compression:: CompressionLayer ;
@@ -266,7 +268,12 @@ impl Adapter<HttpConnector, Body> {
266
268
}
267
269
268
270
async fn is_web_ready ( & self , url : & Url , protocol : & Protocol ) -> bool {
271
+ let mut checkpoint = Checkpoint :: new ( ) ;
269
272
Retry :: spawn ( FixedInterval :: from_millis ( 10 ) , || {
273
+ if checkpoint. lapsed ( ) {
274
+ tracing:: info!( url = %url. to_string( ) , "app is not ready after {}ms" , checkpoint. next_ms( ) ) ;
275
+ checkpoint. increment ( ) ;
276
+ }
270
277
self . check_web_readiness ( url, protocol)
271
278
} )
272
279
. await
@@ -282,10 +289,11 @@ impl Adapter<HttpConnector, Body> {
282
289
&& response. status ( ) . as_u16 ( ) >= 100
283
290
} =>
284
291
{
292
+ tracing:: debug!( "app is ready" ) ;
285
293
Ok ( ( ) )
286
294
}
287
295
_ => {
288
- tracing:: debug !( "app is not ready" ) ;
296
+ tracing:: trace !( "app is not ready" ) ;
289
297
Err ( -1 )
290
298
}
291
299
} ,
0 commit comments