| 1175 | } |
| 1176 | |
| 1177 | bool sendSignalAndWaitForStop(const fs::path & pid_file, int signal, unsigned max_tries, unsigned wait_ms, const char * signal_name) |
| 1178 | { |
| 1179 | int pid = isRunning(pid_file, /*ignore_file_does_not_exist=*/ false); |
| 1180 | |
| 1181 | if (!pid) |
| 1182 | return true; |
| 1183 | |
| 1184 | if (0 == kill(pid, signal)) |
| 1185 | fmt::print("Sent {} signal to process with pid {}.\n", signal_name, pid); |
| 1186 | else |
| 1187 | throw ErrnoException(ErrorCodes::SYSTEM_ERROR, "Cannot send {} signal", signal_name); |
| 1188 | |
| 1189 | size_t try_num = 0; |
| 1190 | for (; try_num < max_tries; ++try_num) |
| 1191 | { |
| 1192 | fmt::print("Waiting for server to stop\n"); |
| 1193 | if (!isRunning(pid_file, /*ignore_file_does_not_exist=*/ true)) |
| 1194 | { |
| 1195 | fmt::print("Server stopped\n"); |
| 1196 | break; |
| 1197 | } |
| 1198 | sleepForMilliseconds(wait_ms); |
| 1199 | } |
| 1200 | |
| 1201 | return try_num < max_tries; |
| 1202 | } |
| 1203 | |
| 1204 | int stop(const fs::path & pid_file, bool force, bool do_not_kill, unsigned max_tries) |
| 1205 | { |
no test coverage detected