Skip to content

Commit

Permalink
chore: log exit code of failing dragonfly in tests (#4166)
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Gershman <[email protected]>
  • Loading branch information
romange authored Nov 22, 2024
1 parent a694bf4 commit b8c2dd8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 4 additions & 6 deletions src/server/dfly_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,12 @@ template <typename... Args> unique_ptr<Listener> MakeListener(Args&&... args) {
return res;
}

bool RunEngine(ProactorPool* pool, AcceptServer* acceptor) {
void RunEngine(ProactorPool* pool, AcceptServer* acceptor) {
uint64_t maxmemory = GetMaxMemoryFlag();
if (maxmemory > 0 && maxmemory < pool->size() * 256_MB) {
LOG(ERROR) << "There are " << pool->size() << " threads, so "
<< HumanReadableNumBytes(pool->size() * 256_MB) << " are required. Exiting...";
return false;
exit(1);
}

Service service(pool);
Expand Down Expand Up @@ -310,8 +310,6 @@ bool RunEngine(ProactorPool* pool, AcceptServer* acceptor) {

version_monitor.Shutdown();
service.Shutdown();

return true;
}

bool CreatePidFile(const string& path) {
Expand Down Expand Up @@ -791,7 +789,7 @@ Usage: dragonfly [FLAGS]
AcceptServer acceptor(pool.get(), &fb2::std_malloc_resource, true);
acceptor.set_back_log(absl::GetFlag(FLAGS_tcp_backlog));

int res = dfly::RunEngine(pool.get(), &acceptor) ? 0 : -1;
dfly::RunEngine(pool.get(), &acceptor);

pool->Stop();

Expand All @@ -803,5 +801,5 @@ Usage: dragonfly [FLAGS]
// This is a workaround for a bug in mi_malloc that may cause a crash on exit.
mi_collect(true);

return res;
return 0;
}
4 changes: 3 additions & 1 deletion tests/dragonfly/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ def stop(self, kill=False):
# if the return code is negative it means termination by signal
# if the return code is positive it means abnormal exit
if proc.returncode != 0:
raise Exception("Dragonfly did not terminate gracefully")
raise Exception(
f"Dragonfly did not terminate gracefully, exit code {proc.returncode}"
)

except subprocess.TimeoutExpired:
# We need to send SIGUSR1 to DF such that it prints the stacktrace
Expand Down

0 comments on commit b8c2dd8

Please sign in to comment.