108{
109 spdlog::trace("Received {} messages", recvMsgs.size());
110 replyMsgs.clear();
111
112 std::string replyBody;
113 int reply = ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL;
114 switch (*(static_cast<const uint64_t *>(recvMsgs[0].data())))
115 {
117 if (recvMsgs.size() != 2)
118 {
119 spdlog::error("Received unknown number of messages for log level change");
120 break;
121 }
122
123 spdlog::warn("Log level change request received");
124 const auto receivedMsg = std::string(static_cast<const char *>(recvMsgs[1].data()), recvMsgs[1].size());
125
126 if (receivedMsg == "v")
127 {
128 spdlog::set_level(spdlog::level::info);
129 }
130 if (receivedMsg == "vv")
131 {
132 spdlog::set_level(spdlog::level::debug);
133 }
134 if (receivedMsg == "vvv")
135 {
136 spdlog::set_level(spdlog::level::trace);
137 }
138 reply = ZMQ_EVENT_HANDSHAKE_SUCCEEDED;
139 break;
140 }
142 if (recvMsgs.size() != 1)
143 {
144 spdlog::error("Received unknown number of messages for version information");
145 break;
146 }
147
148 reply = ZMQ_EVENT_HANDSHAKE_SUCCEEDED;
149 replyBody = PROJECT_FULL_VERSION_STRING;
150 break;
151 }
153 if (recvMsgs.size() != 1)
154 {
155 spdlog::error("Received unknown number of messages for ping");
156 break;
157 }
158
159 reply = ZMQ_EVENT_HANDSHAKE_SUCCEEDED;
160 replyBody = "PONG";
161 break;
162 }
164 if (recvMsgs.size() != 1)
165 {
166 spdlog::error("Received unknown number of messages for status check");
167 break;
168 }
169
170 reply = ZMQ_EVENT_HANDSHAKE_SUCCEEDED;
171
172 std::ostringstream oss;
173 oss << "{";
174 for (
const auto &[process, statusFlag] :
vCheckFlag)
175 {
176 oss << "\"" << process << "\":" << (statusFlag->_M_i ? "1," : "0,");
177 }
178 replyBody = oss.str();
179 replyBody.replace(replyBody.size() - 1, 1, "}");
180 break;
181 }
182
183
184
185
186
187
188
189 default:
190 spdlog::error("Unknown command received from control");
191 break;
192 }
193
194
195 replyMsgs.emplace_back(&reply, sizeof(reply));
196 replyMsgs.emplace_back(replyBody.c_str(), replyBody.size());
197
198 return reply == ZMQ_EVENT_HANDSHAKE_SUCCEEDED;
199}
std::vector< std::pair< std::string, std::shared_ptr< std::atomic_flag > > > vCheckFlag
Global variable to check if the servers are running.
constexpr uint32_t PING_PONG_ID
constexpr uint32_t VERSION_INFO_ID
constexpr uint32_t LOG_LEVEL_ID
constexpr uint32_t STATUS_CHECK_ID