int active = 0;
int partial_pause = 0;
- /* don't touch anything if takeover is in progress */
- if (cf_reboot)
- return;
-
statlist_for_each(item, &pool_list) {
pool = container_of(item, PgPool, head);
if (pool->admin)
List *item;
PgPool *pool;
- /* don't touch anything if takeover is in progress */
- if (cf_reboot)
- goto skip;
-
statlist_for_each(item, &pool_list) {
pool = container_of(item, PgPool, head);
if (pool->admin)
check_pidfile();
if (cf_daemon)
go_daemon();
- if (!cf_reboot)
- write_pidfile();
+ write_pidfile();
}
static void main_loop_once(void)
int main(int argc, char *argv[])
{
int c;
+ int did_takeover = 0;
/* parse cmdline */
while ((c = getopt(argc, argv, "avhdVR")) != EOF) {
cf_config_file = argv[optind];
init_objects();
-
load_config(false);
-
init_caches();
+ admin_setup();
/* need to do that after loading config */
check_limits();
/* init random */
srandom(time(NULL) ^ getpid());
+ if (cf_reboot) {
+ /* use temporary libevent base */
+ void *evtmp = event_init();
+ takeover_init();
+ while (cf_reboot)
+ main_loop_once();
+ did_takeover = 1;
+ event_base_free(evtmp);
+ }
+
/* initialize subsystems, order important */
daemon_setup();
event_init();
signal_setup();
janitor_setup();
stats_setup();
- admin_setup();
- if (cf_reboot) {
- takeover_init();
- while (cf_reboot)
- main_loop_once();
- write_pidfile();
- } else
+ if (!did_takeover)
pooler_setup();
+ else
+ resume_all();
/* main loop */
while (1)
return strcmp(name, user->name);
}
+/* initialization before config loading */
void init_objects(void)
{
tree_init(&user_tree, user_node_cmp, NULL);
}
+/* initialization after config loading */
void init_caches(void)
{
server_cache = objcache_create("server_cache", PG_SOCKET_SIZE, 8,
{
disconnect_server(bouncer, false, "disko over");
cf_reboot = 0;
- resume_all();
log_info("disko over, resuming work");
}