agoo_server_start(agooErr err, const char *app_name, const char *version) {
    double	giveup;
    int		xcnt = 0;
    int		stat;

    if (0 != (stat = pthread_create(&agoo_server.listen_thread, NULL, listen_loop, NULL))) {
	return agoo_err_set(err, stat, "Failed to create server listener thread. %s", strerror(stat));
    }
    xcnt++;
    agoo_server.con_loops = agoo_conloop_create(err, 0);
    agoo_server.loop_cnt = 1;
    xcnt++;

    // If the eval thread count is 1 that implies the eval load is low so
    // might as well create the maximum number of con threads as is
    // reasonable.
    if (1 >= agoo_server.thread_cnt) {
	while (agoo_server.loop_cnt < agoo_server.loop_max) {
	    add_con_loop();
	    xcnt++;
	}
    }
    giveup = dtime() + 1.0;
    while (dtime() < giveup) {
	if (xcnt <= (long)atomic_load(&agoo_server.running)) {
	    break;
	}
	dsleep(0.01);
    }
    if (agoo_info_cat.on) {
	agooBind	b;

	for (b = agoo_server.binds; NULL != b; b = b->next) {
	    agoo_log_cat(&agoo_info_cat, "%s %s with pid %d is listening on %s.", app_name, version, getpid(), b->id);
	}
    }
    return AGOO_ERR_OK;
}
agoo_server_start(agooErr err, const char *app_name, const char *version) {
    double	giveup;
    int		xcnt = 0;
    int		stat;

    if (0 != (stat = pthread_create(&agoo_server.listen_thread, NULL, listen_loop, NULL))) {
	return agoo_err_set(err, stat, "Failed to create server listener thread. %s", strerror(stat));
    }
    xcnt++;
    agoo_server.con_loops = agoo_conloop_create(err, 0);
    agoo_server.loop_cnt = 1;
    xcnt++;

     
     
     
    if (1 >= agoo_server.thread_cnt) {
	while (agoo_server.loop_cnt < agoo_server.loop_max) {
	    add_con_loop();
	    xcnt++;
	}
    }
    giveup = dtime() + 1.0;
    while (dtime() < giveup) {
	if (xcnt <= (long)atomic_load(&agoo_server.running)) {
	    break;
	}
	dsleep(0.01);
    }
    if (agoo_info_cat.on) {
	agooBind	b;

	for (b = agoo_server.binds; NULL != b; b = b->next) {
	    agoo_log_cat(&agoo_info_cat, "%s %s with pid %d is listening on %s.", app_name, version, getpid(), b->id);
	}
    }
    return AGOO_ERR_OK;
}