feat(ha-config-bootstrap): extract cluster_open_listener, reorder startup before election (task 3.2)
This commit is contained in:
parent
0a881804a0
commit
6272fc8eb2
4 changed files with 94 additions and 28 deletions
|
|
@ -48,6 +48,26 @@ int myapp_run(myconf_t* myconf)
|
|||
}
|
||||
c.ha.ssl_ctx = ssl_ctx;
|
||||
|
||||
/* Req 1.1: open the listener socket before any election probe so that
|
||||
* concurrent-startup peers can reach this node's vote handler. */
|
||||
rc = cluster_open_listener(&c);
|
||||
if (rc < 0) {
|
||||
ERROR("cluster_open_listener: %s", strerror(-rc));
|
||||
cluster_fini(&c);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Req 1.2: initialise the I/O manager and virtual task manager before
|
||||
* election so that incoming vote requests are handled by the normal
|
||||
* dispatch loop once it starts. */
|
||||
iomgr_init(&(c.iomgr));
|
||||
iomgr_set_ssl_ctx(&(c.iomgr), ssl_ctx);
|
||||
|
||||
{
|
||||
int nvcpus = (myconf->vcpus > 0) ? myconf->vcpus : 8;
|
||||
vtaskmgr_init(&(c.vtaskmgr), nvcpus);
|
||||
}
|
||||
|
||||
/* Election: determine role before loading config.
|
||||
* Capture result once — am_i_primary() probes peers and is expensive. */
|
||||
int is_primary = am_i_primary(&c);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue