@@ -49,6 +49,7 @@ const META_METHOD_PUSH_LOG: MetaMethod = MetaMethod::new_static(METH_PUSH_LOG, s
4949const METH_VERSION : & str = "version" ;
5050const METH_UPTIME : & str = "uptime" ;
5151const METH_RELOAD_SITES : & str = "reloadSites" ;
52+ const METH_LAST_SITES_LOADED : & str = "lastSitesLoaded" ;
5253
5354// File nodes methods
5455const METH_HASH : & str = "hash" ;
@@ -615,6 +616,7 @@ pub(crate) async fn request_handler(
615616 MetaMethod :: new_static ( METH_VERSION , shvrpc:: metamethod:: Flags :: None , AccessLevel :: Read , "Null" , "String" , & [ ] , "" ) ,
616617 MetaMethod :: new_static ( METH_UPTIME , shvrpc:: metamethod:: Flags :: None , AccessLevel :: Read , "Null" , "String" , & [ ] , "" ) ,
617618 MetaMethod :: new_static ( METH_RELOAD_SITES , shvrpc:: metamethod:: Flags :: None , AccessLevel :: Write , "Null" , "Bool" , & [ ] , "" ) ,
619+ MetaMethod :: new_static ( METH_LAST_SITES_LOADED , shvrpc:: metamethod:: Flags :: None , AccessLevel :: Read , "Null" , "DateTime" , & [ ] , "" ) ,
618620 META_METHOD_ALARM_LOG ,
619621 // TODO: All root node methods:
620622 // appName
@@ -654,6 +656,9 @@ pub(crate) async fn request_handler(
654656 sites_cmd_tx. unbounded_send ( crate :: sites:: SitesCommand :: ReloadSites ) . map_err ( |err| RpcError :: new ( RpcErrorCode :: InternalError , format ! ( "Couldn't reload sites: {err}" ) ) ) ?;
655657 Ok ( "Sites queued for a reload. This might take a while." . to_string ( ) )
656658 } ) ,
659+ METH_LAST_SITES_LOADED => m. resolve ( METHODS , async move || {
660+ Ok ( app_state. last_sites_loaded . read ( ) . await . map ( |last_sites_loaded| humantime:: format_duration ( std:: time:: Duration :: from_secs ( last_sites_loaded. elapsed ( ) . as_secs ( ) ) ) . to_string ( ) ) )
661+ } ) ,
657662 _ => err_unresolved_request ( ) ,
658663 }
659664 }
0 commit comments