+ shutdown(true);
+}
+
+bool server_startup_st::is_debug() const
+{
+ return bool(getenv("LIBTEST_MANUAL_GDB"));
+}
+
+bool server_startup_st::is_valgrind() const
+{
+ return bool(getenv("LIBTEST_MANUAL_VALGRIND"));
+}
+
+bool server_startup_st::is_helgrind() const
+{
+ return bool(getenv("LIBTEST_MANUAL_HELGRIND"));
+}
+
+
+bool server_startup(server_startup_st& construct, const std::string& server_type, in_port_t try_port, int argc, const char *argv[])
+{
+ Outn();
+
+ // Look to see if we are being provided ports to use
+ {
+ char variable_buffer[1024];
+ snprintf(variable_buffer, sizeof(variable_buffer), "LIBTEST_PORT_%lu", (unsigned long)construct.count());
+
+ char *var;
+ if ((var= getenv(variable_buffer)))
+ {
+ in_port_t tmp= in_port_t(atoi(var));
+
+ if (tmp > 0)
+ try_port= tmp;
+ }
+ }
+
+ Server *server= NULL;
+ if (0)
+ { }
+ else if (server_type.compare("gearmand") == 0)
+ {
+#ifdef GEARMAND_BINARY
+ #ifdef HAVE_LIBGEARMAN
+ server= build_gearmand("localhost", try_port);
+ #else
+ Error << "Libgearman was not found";
+ #endif
+#else
+ Error << "No gearmand binary is available";
+#endif
+ }
+ else if (server_type.compare("memcached") == 0)
+ {
+#ifdef MEMCACHED_BINARY
+#ifdef HAVE_LIBMEMCACHED
+ server= build_memcached("localhost", try_port);
+#else
+ Error << "Libmemcached was not found";
+#endif
+#else
+ Error << "No memcached binary is available";
+#endif
+ }
+ else
+ {
+ Error << "Failed to start " << server_type << ", no support was found to be compiled in for it.";
+ }
+
+ if (server == NULL)
+ {
+ Error << "Failure occured while creating server: " << server_type;
+ return false;
+ }
+
+ /*
+ We will now cycle the server we have created.
+ */
+ if (not server->cycle())
+ {
+ Error << "Could not start up server " << *server;
+ delete server;
+ return false;
+ }
+
+ server->build(argc, argv);
+
+ if (construct.is_debug())
+ {
+ Out << "Pausing for startup, hit return when ready.";
+ std::string gdb_command= server->base_command();
+ std::string options;
+ Out << "run " << server->args(options);
+ getchar();
+ }
+ else if (not server->start())
+ {
+ Error << "Failed to start " << *server;
+ delete server;
+ return false;
+ }
+ else
+ {
+ Out << "STARTING SERVER(pid:" << server->pid() << "): " << server->running();
+ }
+
+ construct.push_server(server);
+
+ if (default_port() == 0)
+ {
+ assert(server->has_port());
+ set_default_port(server->port());
+ }
+
+ Outn();
+
+ return true;
+}
+
+bool server_startup_st::start_socket_server(const std::string& server_type, const in_port_t try_port, int argc, const char *argv[])
+{
+ (void)try_port;
+ Outn();
+
+ Server *server= NULL;
+ if (0)
+ { }
+ else if (server_type.compare("gearmand") == 0)
+ {
+ Error << "Socket files are not supported for gearmand yet";
+ }
+ else if (server_type.compare("memcached") == 0)
+ {
+#ifdef MEMCACHED_BINARY
+#ifdef HAVE_LIBMEMCACHED
+ server= build_memcached_socket("localhost", try_port);
+#else
+ Error << "Libmemcached was not found";
+#endif
+#else
+ Error << "No memcached binary is available";
+#endif
+ }
+ else
+ {
+ Error << "Failed to start " << server_type << ", no support was found to be compiled in for it.";
+ }
+
+ if (server == NULL)
+ {
+ Error << "Failure occured while creating server: " << server_type;
+ return false;
+ }
+
+ /*
+ We will now cycle the server we have created.
+ */
+ if (not server->cycle())