feat(controller-peers-env-fallback): flush the controller's log before every early exit (task 2.2)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Rongsong Shen 2026-10-03 06:04:19 +00:00
parent 7a90af089c
commit 25e2807355
Signed by untrusted user: rshen
GPG key ID: 80533536B0EB651C
3 changed files with 47 additions and 1 deletions

View file

@ -392,6 +392,10 @@ int main(int argc, char* argv[])
mylog_init(logfile, loglevel, logsize, logcount);
/* tlog writes the log file from a background thread and has no atexit
* flush, so every early return below calls mylog_fini() (tlog_exit())
* first; otherwise lines logged just before the return can be lost. */
if (arguments.workdir == NULL) {
INFO("no cluster work directory specified. The default work directory "
"`" DEFAULT_WORKDIR "' will be used.");
@ -401,6 +405,7 @@ int main(int argc, char* argv[])
if (arguments.myname == NULL) {
if (get_myname(myname, sizeof(myname) - 1) < 0) {
ERROR("get_myname");
mylog_fini();
return -1;
}
arguments.myname = myname;
@ -449,6 +454,7 @@ int main(int argc, char* argv[])
* cluster_run/myapp_run can ever call it. */
if (mylock_init(&myconf.lock) != 0) {
ERROR("Failed to initialize myconf lock");
mylog_fini();
return -1;
}
@ -458,6 +464,7 @@ int main(int argc, char* argv[])
"xce_controller: --peers parse error: expected "
"host:port,... got: %s\n",
arguments.peers_str);
mylog_fini();
return 1;
}
@ -468,6 +475,7 @@ int main(int argc, char* argv[])
"allowed; Raft quorum requires an odd number of nodes "
"(1, 3, 5, ...)\n",
myconf.peers_cfg.candidates_count);
mylog_fini();
return 1;
}
@ -492,6 +500,7 @@ int main(int argc, char* argv[])
if (validate_cert_files(cert_file, key_file,
cert_err, sizeof(cert_err)) != 0) {
fprintf(stderr, "xce_controller: %s\n", cert_err);
mylog_fini();
return 1;
}
}