Take server destruction into use
The servers can now be destroyed with the `destroy server NAME` maxadmin command.
This commit is contained in:
@ -249,7 +249,8 @@ bool server_serialize(SERVER *server);
|
|||||||
* This removes any created server configuration files and marks the server removed
|
* This removes any created server configuration files and marks the server removed
|
||||||
* If the server is not in use.
|
* If the server is not in use.
|
||||||
* @param server Server to destroy
|
* @param server Server to destroy
|
||||||
|
* @return True if server was destroyed
|
||||||
*/
|
*/
|
||||||
void server_destroy(SERVER *server);
|
bool server_destroy(SERVER *server);
|
||||||
|
|
||||||
MXS_END_DECLS
|
MXS_END_DECLS
|
||||||
|
|||||||
@ -1242,8 +1242,10 @@ bool server_serialize(SERVER *server)
|
|||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void server_destroy(SERVER *server)
|
bool server_destroy(SERVER *server)
|
||||||
{
|
{
|
||||||
|
bool rval = false;
|
||||||
|
|
||||||
if (service_server_in_use(server) || monitor_server_in_use(server))
|
if (service_server_in_use(server) || monitor_server_in_use(server))
|
||||||
{
|
{
|
||||||
MXS_ERROR("Cannot destroy server '%s' as it is used by at least one "
|
MXS_ERROR("Cannot destroy server '%s' as it is used by at least one "
|
||||||
@ -1265,16 +1267,28 @@ void server_destroy(SERVER *server)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
rval = true;
|
||||||
MXS_WARNING("Server '%s' was not created at runtime. Remove the "
|
MXS_WARNING("Server '%s' was not created at runtime. Remove the "
|
||||||
"server manually from the correct configuration file.",
|
"server manually from the correct configuration file.",
|
||||||
server->unique_name);
|
server->unique_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rval = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rval)
|
||||||
|
{
|
||||||
|
MXS_NOTICE("Destroyed server '%s' at %s:%u", server->unique_name,
|
||||||
|
server->name, server->port);
|
||||||
server->is_active = false;
|
server->is_active = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return rval;
|
||||||
|
}
|
||||||
|
|
||||||
bool server_is_ssl_parameter(const char *key)
|
bool server_is_ssl_parameter(const char *key)
|
||||||
{
|
{
|
||||||
// TODO: Implement this
|
// TODO: Implement this
|
||||||
|
|||||||
@ -1023,9 +1023,9 @@ static void createServer(DCB *dcb, char *name, char *address, char *port,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dcb_printf(dcb, "WARNING: The server was added to the runtime "
|
dcb_printf(dcb, "WARNING: The server was added to the runtime \n"
|
||||||
"configuration but persisting the new server to disk "
|
"configuration but persisting the new server to disk \n"
|
||||||
"failed. This server will NOT be loaded when MaxScale "
|
"failed. This server will NOT be loaded when MaxScale \n"
|
||||||
"is restarted. See log file for more details on why it failed.\n");
|
"is restarted. See log file for more details on why it failed.\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1068,7 +1068,20 @@ struct subcommand createoptions[] =
|
|||||||
|
|
||||||
static void destroyServer(DCB *dcb, SERVER *server)
|
static void destroyServer(DCB *dcb, SERVER *server)
|
||||||
{
|
{
|
||||||
dcb_printf(dcb, "Not yet implemented.\n");
|
/** Do this so that we don't directly access the server. Currently, the
|
||||||
|
* destruction of a server does not free any memory and the server stays
|
||||||
|
* valid. */
|
||||||
|
char name[strlen(server->unique_name) + 1];
|
||||||
|
strcpy(name, server->unique_name);
|
||||||
|
|
||||||
|
if (server_destroy(server))
|
||||||
|
{
|
||||||
|
dcb_printf(dcb, "Destroyed server '%s'\n", name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dcb_printf(dcb, "Failed to destroy server '%s', see log file for more details\n", name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct subcommand destroyoptions[] =
|
struct subcommand destroyoptions[] =
|
||||||
@ -1077,7 +1090,7 @@ struct subcommand destroyoptions[] =
|
|||||||
"server", 1, 1, destroyServer,
|
"server", 1, 1, destroyServer,
|
||||||
"Destroy a server",
|
"Destroy a server",
|
||||||
"Usage: destroy server NAME",
|
"Usage: destroy server NAME",
|
||||||
{ARG_TYPE_STRING}
|
{ARG_TYPE_SERVER}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
EMPTY_OPTION
|
EMPTY_OPTION
|
||||||
|
|||||||
Reference in New Issue
Block a user