From 840ac20855855b134662683ca3e7d9e364d4bca8 Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 4 May 2016 12:45:55 +0200 Subject: [PATCH] DEBUG command self documentation. --- src/debug.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- src/server.c | 2 +- 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/src/debug.c b/src/debug.c index cd0469c7..1e179caf 100644 --- a/src/debug.c +++ b/src/debug.c @@ -259,7 +259,54 @@ void inputCatSds(void *result, const char *str) { #endif void debugCommand(client *c) { - if (!strcasecmp(c->argv[1]->ptr,"segfault")) { + if (c->argc == 1) { + addReplyError(c,"You must specify a subcommand for DEBUG. Try DEBUG HELP for info."); + return; + } + + if (!strcasecmp(c->argv[1]->ptr,"help")) { + void *blenp = addDeferredMultiBulkLength(c); + int blen = 0; + blen++; addReplyStatus(c, + "DEBUG arg arg ... arg. Subcommands:"); + blen++; addReplyStatus(c, + "segfault -- Crash the server with sigsegv."); + blen++; addReplyStatus(c, + "restart -- Graceful restart: save config, db, restart."); + blen++; addReplyStatus(c, + "crash-and-recovery -- Hard crash and restart after delay."); + blen++; addReplyStatus(c, + "assert -- Crash by assertion failed."); + blen++; addReplyStatus(c, + "reload -- Save the RDB on disk and reload it back in memory."); + blen++; addReplyStatus(c, + "loadaof -- Flush the AOF buffers on disk and reload the AOF in memory."); + blen++; addReplyStatus(c, + "object -- Show low level info about key and associated value."); + blen++; addReplyStatus(c, + "sdslen -- Show low level SDS string info representing key and value."); + blen++; addReplyStatus(c, + "populate [prefix] -- Create string keys named key:. If a prefix is specified is used instead of the 'key' prefix."); + blen++; addReplyStatus(c, + "digest -- Outputs an hex signature representing the current DB content."); + blen++; addReplyStatus(c, + "sleep -- Stop the server for . Decimals allowed."); + blen++; addReplyStatus(c, + "set-active-expire (0|1) -- Setting it to 0 disables expiring keys in background when they are not accessed (otherwise the Redis behavior). Setting it to 1 reenables back the default."); + blen++; addReplyStatus(c, + "lua-always-replicate-commands (0|1) -- Setting it to 1 makes Lua replication defaulting to replicating single commands, without the script having to enable effects replication."); + blen++; addReplyStatus(c, + "error -- Return a Redis protocol error with as message. Useful for clients unit tests to simulate Redis errors."); + blen++; addReplyStatus(c, + "structsize -- Return the size of different Redis core C structures."); + blen++; addReplyStatus(c, + "htstats -- Return hash table statistics of the specified Redis database."); + blen++; addReplyStatus(c, + "jemalloc info -- Show internal jemalloc statistics."); + blen++; addReplyStatus(c, + "jemalloc purge -- Force jemalloc to release unused memory."); + setDeferredMultiBulkLength(c,blenp,blen); + } else if (!strcasecmp(c->argv[1]->ptr,"segfault")) { *((char*)-1) = 'x'; } else if (!strcasecmp(c->argv[1]->ptr,"restart") || !strcasecmp(c->argv[1]->ptr,"crash-and-recover")) diff --git a/src/server.c b/src/server.c index 484716ab..7a02cb8b 100644 --- a/src/server.c +++ b/src/server.c @@ -253,7 +253,7 @@ struct redisCommand redisCommandTable[] = { {"persist",persistCommand,2,"wF",0,NULL,1,1,1,0,0}, {"slaveof",slaveofCommand,3,"ast",0,NULL,0,0,0,0,0}, {"role",roleCommand,1,"lst",0,NULL,0,0,0,0,0}, - {"debug",debugCommand,-2,"as",0,NULL,0,0,0,0,0}, + {"debug",debugCommand,-1,"as",0,NULL,0,0,0,0,0}, {"config",configCommand,-2,"art",0,NULL,0,0,0,0,0}, {"subscribe",subscribeCommand,-2,"rpslt",0,NULL,0,0,0,0,0}, {"unsubscribe",unsubscribeCommand,-1,"rpslt",0,NULL,0,0,0,0,0},