@@ -13,6 +13,7 @@ use rocket_vsock_listener::VsockListener;
1313use rpc_service:: { AppState , ExternalRpcHandler , InternalRpcHandler , InternalRpcHandlerV0 } ;
1414use sd_notify:: { notify as sd_notify, NotifyState } ;
1515use std:: time:: Duration ;
16+ use tokio:: sync:: oneshot;
1617use tracing:: { error, info} ;
1718
1819mod config;
@@ -44,7 +45,11 @@ struct Args {
4445 watchdog : bool ,
4546}
4647
47- async fn run_internal_v0 ( state : AppState , figment : Figment ) -> Result < ( ) > {
48+ async fn run_internal_v0 (
49+ state : AppState ,
50+ figment : Figment ,
51+ sock_ready_tx : oneshot:: Sender < ( ) > ,
52+ ) -> Result < ( ) > {
4853 let rocket = rocket:: custom ( figment)
4954 . mount (
5055 "/prpc/" ,
@@ -64,14 +69,19 @@ async fn run_internal_v0(state: AppState, figment: Figment) -> Result<()> {
6469 // Allow any user to connect to the socket
6570 fs_err:: set_permissions ( path, Permissions :: from_mode ( 0o777 ) ) ?;
6671 }
72+ sock_ready_tx. send ( ( ) ) . ok ( ) ;
6773 ignite
6874 . launch_on ( listener)
6975 . await
7076 . map_err ( |err| anyhow ! ( err. to_string( ) ) ) ?;
7177 Ok ( ( ) )
7278}
7379
74- async fn run_internal ( state : AppState , figment : Figment ) -> Result < ( ) > {
80+ async fn run_internal (
81+ state : AppState ,
82+ figment : Figment ,
83+ sock_ready_tx : oneshot:: Sender < ( ) > ,
84+ ) -> Result < ( ) > {
7585 let rocket = rocket:: custom ( figment)
7686 . mount ( "/" , ra_rpc:: prpc_routes!( AppState , InternalRpcHandler ) )
7787 . manage ( state) ;
@@ -88,6 +98,7 @@ async fn run_internal(state: AppState, figment: Figment) -> Result<()> {
8898 // Allow any user to connect to the socket
8999 fs_err:: set_permissions ( path, Permissions :: from_mode ( 0o777 ) ) ?;
90100 }
101+ sock_ready_tx. send ( ( ) ) . ok ( ) ;
91102 ignite
92103 . launch_on ( listener)
93104 . await
@@ -204,12 +215,16 @@ async fn main() -> Result<()> {
204215 . extract ( )
205216 . context ( "Failed to extract bind address" ) ?;
206217 let guest_api_figment = figment. select ( "guest-api" ) ;
218+ let ( tappd_ready_tx, tappd_ready_rx) = oneshot:: channel ( ) ;
219+ let ( sock_ready_tx, sock_ready_rx) = oneshot:: channel ( ) ;
207220 tokio:: select!(
208- res = run_internal_v0( state. clone( ) , internal_v0_figment) => res?,
209- res = run_internal( state. clone( ) , internal_figment) => res?,
221+ res = run_internal_v0( state. clone( ) , internal_v0_figment, tappd_ready_tx ) => res?,
222+ res = run_internal( state. clone( ) , internal_figment, sock_ready_tx ) => res?,
210223 res = run_external( state. clone( ) , external_figment) => res?,
211224 res = run_guest_api( state. clone( ) , guest_api_figment) => res?,
212225 _ = async {
226+ let _ = tappd_ready_rx. await ;
227+ let _ = sock_ready_rx. await ;
213228 if args. watchdog {
214229 run_watchdog( bind_addr. port) . await ;
215230 } else {
0 commit comments