Skip to content

Commit

Permalink
DEBUG RESTART/CRASH-AND-RECOVER [delay] implemented.
Browse files Browse the repository at this point in the history
  • Loading branch information
antirez committed Oct 13, 2015
1 parent 7342746 commit 35a0c77
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/debug.c
Expand Up @@ -259,6 +259,20 @@ void inputCatSds(void *result, const char *str) {
void debugCommand(client *c) {
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"))
{
long long delay = 0;
if (c->argc >= 3) {
if (getLongLongFromObjectOrReply(c, c->argv[2], &delay, NULL)
!= C_OK) return;
if (delay < 0) delay = 0;
}
int flags = !strcasecmp(c->argv[1]->ptr,"restart") ?
(RESTART_SERVER_GRACEFULLY|RESTART_SERVER_CONFIG_REWRITE) :
RESTART_SERVER_NONE;
restartServer(flags,delay);
addReplyError(c,"failed to restart the server. Check server logs.");
} else if (!strcasecmp(c->argv[1]->ptr,"oom")) {
void *ptr = zmalloc(ULONG_MAX); /* Should trigger an out of memory. */
zfree(ptr);
Expand Down
3 changes: 3 additions & 0 deletions src/server.c
Expand Up @@ -1601,6 +1601,9 @@ extern char **environ;
/* Restart the server, executing the same executable that started this
* instance, with the same arguments and configuration file.
*
* The function is designed to directly call execve() so that the new
* server instance will retain the PID of the previous one.
*
* The list of flags, that may be bitwise ORed together, alter the
* behavior of this function:
*
Expand Down

0 comments on commit 35a0c77

Please sign in to comment.