@@ -45,6 +45,7 @@ void RelayServer::runWebsocket(ThreadPool<MsgWebsocket>::Thread &thr) {
4545 flat_hash_map<uint64_t , Connection*> connIdToConnection;
4646 uint64_t nextConnectionId = 1 ;
4747 bool gracefulShutdown = false ;
48+ uint64_t serverStart = ::time (nullptr );
4849
4950 std::string tempBuf;
5051 tempBuf.reserve (cfg ().events__maxEventSize + MAX_SUBID_SIZE + 100 );
@@ -102,8 +103,8 @@ void RelayServer::runWebsocket(ThreadPool<MsgWebsocket>::Thread &thr) {
102103 return std::string_view (rendered); // memory only valid until next call
103104 };
104105
105- auto getLandingPageHttpResponse = [&supportedNips, ver = uint64_t (0 ), rendered = std::string (" " )]() mutable {
106- if (ver != cfg ().version ()) {
106+ auto getLandingPageHttpResponse = [&supportedNips, &serverStart, ver = uint64_t ( 0 ), lastUpdate = uint64_t (0 ), rendered = std::string (" " )]() mutable {
107+ if (ver != cfg ().version () || ( uint64_t ):: time ( nullptr ) - lastUpdate > 3600 ) {
107108 auto maybeUrl = [](std::string_view inp){
108109 if (inp.starts_with (" http://" ) || inp.starts_with (" https://" )) {
109110 std::string output = " <a href=\" " ;
@@ -121,10 +122,12 @@ void RelayServer::runWebsocket(ThreadPool<MsgWebsocket>::Thread &thr) {
121122 std::string version;
122123 uint64_t negentropy;
123124 std::function<std::string(std::string_view)> maybeUrl;
124- } ctx = { tao::json::to_string (supportedNips ()), APP_GIT_VERSION , negentropy::PROTOCOL_VERSION - 0x60 , maybeUrl };
125+ uint64_t uptime;
126+ } ctx = { tao::json::to_string (supportedNips ()), APP_GIT_VERSION , negentropy::PROTOCOL_VERSION - 0x60 , maybeUrl, (uint64_t )::time (nullptr ) - serverStart };
125127
126128 rendered = preGenerateHttpResponse(" text/html" , ::strfrytmpl::landing(ctx).str);
127129 ver = cfg().version();
130+ lastUpdate = ::time(nullptr );
128131 }
129132
130133 return std::string_view(rendered); // memory only valid until next call
0 commit comments