MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / configCommand

Function configCommand

src/config.cpp:3020–3066  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3018 *----------------------------------------------------------------------------*/
3019
3020void configCommand(client *c) {
3021 /* Only allow CONFIG GET while loading. */
3022 if (g_pserver->loading && strcasecmp(szFromObj(c->argv[1]),"get")) {
3023 addReplyError(c,"Only CONFIG GET is allowed during loading");
3024 return;
3025 }
3026
3027 if (c->argc == 2 && !strcasecmp(szFromObj(c->argv[1]),"help")) {
3028 const char *help[] = {
3029"GET <pattern>",
3030" Return parameters matching the glob-like <pattern> and their values.",
3031"SET <directive> <value>",
3032" Set the configuration <directive> to <value>.",
3033"RESETSTAT",
3034" Reset statistics reported by the INFO command.",
3035"REWRITE",
3036" Rewrite the configuration file.",
3037NULL
3038 };
3039
3040 addReplyHelp(c, help);
3041 } else if (!strcasecmp(szFromObj(c->argv[1]),"set") && c->argc >= 3) {
3042 configSetCommand(c);
3043 } else if (!strcasecmp(szFromObj(c->argv[1]),"get") && c->argc == 3) {
3044 configGetCommand(c);
3045 } else if (!strcasecmp(szFromObj(c->argv[1]),"resetstat") && c->argc == 2) {
3046 resetServerStats();
3047 resetCommandTableStats();
3048 resetErrorTableStats();
3049 addReply(c,shared.ok);
3050 } else if (!strcasecmp(szFromObj(c->argv[1]),"rewrite") && c->argc == 2) {
3051 if (cserver.configfile == NULL) {
3052 addReplyError(c,"The server is running without a config file");
3053 return;
3054 }
3055 if (rewriteConfig(cserver.configfile, 0) == -1) {
3056 serverLog(LL_WARNING,"CONFIG REWRITE failed: %s", strerror(errno));
3057 addReplyErrorFormat(c,"Rewriting config file: %s", strerror(errno));
3058 } else {
3059 serverLog(LL_WARNING,"CONFIG REWRITE executed with success.");
3060 addReply(c,shared.ok);
3061 }
3062 } else {
3063 addReplySubcommandSyntaxError(c);
3064 return;
3065 }
3066}

Callers

nothing calls this directly

Calls 13

szFromObjFunction · 0.85
addReplyErrorFunction · 0.85
addReplyHelpFunction · 0.85
configSetCommandFunction · 0.85
configGetCommandFunction · 0.85
resetServerStatsFunction · 0.85
resetCommandTableStatsFunction · 0.85
resetErrorTableStatsFunction · 0.85
addReplyFunction · 0.85
rewriteConfigFunction · 0.85
serverLogFunction · 0.85
addReplyErrorFormatFunction · 0.85

Tested by

no test coverage detected