- uint32_t port_base= 0;
- for (uint32_t x= 0; x < (construct->count -1); x++)
- {
- server_st &server= construct->server[x];
-
- {
- char *var;
- char variable_buffer[1024];
-
- snprintf(variable_buffer, sizeof(variable_buffer), "LIBMEMCACHED_PORT_%u", x);
-
- if ((var= getenv(variable_buffer)))
- {
- server.set_port((in_port_t)atoi(var));
- }
- else
- {
- server.set_port(in_port_t(x + TEST_PORT_BASE + port_base));
-
- while (not cycle_server(server))
- {
- std::cerr << CERR_PREFIX << "Found server " << server << ", could not flush it, so trying next port." << std::endl;
- port_base++;
- server.set_port(in_port_t(x + TEST_PORT_BASE + port_base));
- }
- }
- }
-
- if (server.is_used())
- {
- std::cerr << std::endl << "Using server at : " << server << std::endl;
- }
- else
- {
- char buffer[FILENAME_MAX];
- if (x == 0)
- {
- snprintf(buffer, sizeof(buffer), "%s -d -t 1 -p %u -U %u -m 128",
- MEMCACHED_BINARY, server.port(), server.port());
- }
- else
- {
- snprintf(buffer, sizeof(buffer), "%s -d -t 1 -p %u -U %u",
- MEMCACHED_BINARY, server.port(), server.port());
- }
- server.set_command(buffer);
-
- if (not server.start())
- {
- std::cerr << CERR_PREFIX << "Failed system(" << buffer << ")" << std::endl;
- return false;
- }
- std::cerr << "STARTING SERVER: " << buffer << " pid:" << server.pid() << std::endl;
- }
-
- server_config_string+= "--server=";
- server_config_string+= server.hostname;
- server_config_string+= ":";
- server_config_string+= boost::lexical_cast<std::string>(server.port());
- server_config_string+= " ";
- }