Skip to content

Commit 644c41d

Browse files
committed
feat server: open monitor port early
commit_hash:ead7322200fed5f6078e18c67fe99651b2f13b1d
1 parent b58ab5b commit 644c41d

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

core/functional_tests/early_monitor_port_open/tests/test_boot.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import asyncio
22

33
import aiohttp
4-
import pytest
54

65

7-
@pytest.mark.skip(reason='the feature is not yet enabled')
86
async def test_monitor_port_is_open_before_all_components_are_ready(
97
ensure_daemon_started,
108
service_daemon_scope,

core/include/userver/server/server.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class Server final : public congestion_control::Limitee, public congestion_contr
5353

5454
const http::HttpRequestHandler& GetHttpRequestHandler(bool is_monitor = false) const;
5555

56+
void StartMonitorPort();
5657
void Start();
5758

5859
void Stop();

core/src/server/component.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ Server::Server(
4444
statistics_storage.RegisterWriter("http.handler.total", [this](utils::statistics::Writer& writer) {
4545
return server_->WriteTotalHandlerStatistics(writer);
4646
});
47+
48+
server_->StartMonitorPort();
4749
}
4850

4951
Server::~Server() {

core/src/server/server.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ class ServerImpl final {
112112
);
113113
~ServerImpl();
114114

115-
void StartPortInfos();
115+
void StartPortInfo();
116+
void StartMonitorPortInfo();
116117
void Stop();
117118

118119
void AddHandler(const handlers::HttpHandlerBase& handler, engine::TaskProcessor& task_processor);
@@ -178,7 +179,7 @@ ServerImpl::ServerImpl(
178179

179180
ServerImpl::~ServerImpl() { Stop(); }
180181

181-
void ServerImpl::StartPortInfos() {
182+
void ServerImpl::StartPortInfo() {
182183
UASSERT(main_port_info_.request_handler);
183184

184185
if (has_requests_view_watchers_.load()) {
@@ -189,12 +190,14 @@ void ServerImpl::StartPortInfos() {
189190
}
190191

191192
main_port_info_.Start();
193+
192194
main_port_info_.request_handler->DisableAddHandler();
193195
if (monitor_port_info_.request_handler) {
194196
monitor_port_info_.request_handler->DisableAddHandler();
195197
}
198+
}
196199

197-
// TODO: move to ctr for early start
200+
void ServerImpl::StartMonitorPortInfo() {
198201
if (monitor_port_info_.request_handler) {
199202
monitor_port_info_.Start();
200203
} else {
@@ -383,10 +386,17 @@ const http::HttpRequestHandler& Server::GetHttpRequestHandler(bool is_monitor) c
383386
return pimpl_->GetHttpRequestHandler(is_monitor);
384387
}
385388

389+
void Server::StartMonitorPort()
390+
{
391+
LOG_INFO() << "Starting monitor port";
392+
pimpl_->StartMonitorPortInfo();
393+
LOG_INFO() << "Monitor port is started";
394+
}
395+
386396
void Server::Start() {
387-
LOG_INFO() << "Starting server";
388-
pimpl_->StartPortInfos();
389-
LOG_INFO() << "Server is started";
397+
LOG_INFO() << "Starting server port";
398+
pimpl_->StartPortInfo();
399+
LOG_INFO() << "Server port is started";
390400
}
391401

392402
void Server::Stop() { pimpl_->Stop(); }

0 commit comments

Comments
 (0)