Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
d99a7246
Commit
d99a7246
authored
Mar 26, 2014
by
Matt Stancliff
Committed by
antirez
Aug 07, 2014
Browse files
Add graceful exit when Ctrl-C is received
parent
c82e0b70
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/redis.c
View file @
d99a7246
...
...
@@ -3399,10 +3399,21 @@ void redisAsciiArt(void) {
zfree
(
buf
);
}
static
void
sigtermHandler
(
int
sig
)
{
REDIS_NOTUSED
(
sig
);
redisLogFromHandler
(
REDIS_WARNING
,
"Received SIGTERM, scheduling shutdown..."
);
static
void
sigShutdownHandler
(
int
sig
)
{
char
*
msg
;
switch
(
sig
)
{
case
SIGINT
:
msg
=
"Received SIGINT scheduling shutdown..."
;
break
;
case
SIGTERM
:
msg
=
"Received SIGTERM scheduling shutdown..."
;
break
;
default:
msg
=
"Received shutdown signal, scheduling shutdown..."
;
};
redisLogFromHandler
(
REDIS_WARNING
,
msg
);
server
.
shutdown_asap
=
1
;
}
...
...
@@ -3413,8 +3424,9 @@ void setupSignalHandlers(void) {
* Otherwise, sa_handler is used. */
sigemptyset
(
&
act
.
sa_mask
);
act
.
sa_flags
=
0
;
act
.
sa_handler
=
sig
term
Handler
;
act
.
sa_handler
=
sig
Shutdown
Handler
;
sigaction
(
SIGTERM
,
&
act
,
NULL
);
signal
(
SIGINT
,
sigShutdownHandler
);
#ifdef HAVE_BACKTRACE
sigemptyset
(
&
act
.
sa_mask
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment