Ensure exit is possible

If shutdown has been initiated (via maxadmin or by sending a
SIGINT or SIGTERM) and a SIGTERM is received, the process
is terminated.

If shutdown has been initiated (via maxadmin or by sending a
SIGINT or SIGTERM) and a SIGINT (Ctrl-C) is received, a warning
is printed that shutdown is in progess. Then, if an additional
SIGINT is received, the process is terminated.

So, in practice:
- If MaxScale is running as a daemon, the first SIGTERM initiates
  shutdown and a second one unconditionally terminates the process.
- If MaxScale is running in the console, the first Ctrl-C initiates
  shutdown, the second prints a warning and the third terminates
  the process.

This is to ensure that MaxScale can be forced to exit, in
case some thread is hung for whatever reason, and is thus preventing
the controlled shutdown.
This commit is contained in:
Johan Wikman
2016-11-09 15:30:38 +02:00
parent c28ffcf87e
commit bc1c2e1152
3 changed files with 60 additions and 13 deletions

View File

@ -70,6 +70,7 @@
#include <debugcli.h>
#include <maxscale/housekeeper.h>
#include <maxscale/listmanager.h>
#include <maxscale/maxscale.h>
#include <maxscale/log_manager.h>
#include <sys/syslog.h>
@ -276,7 +277,11 @@ struct subcommand listoptions[] = {
{0, 0, 0} }
};
extern void shutdown_server();
static void shutdown_server()
{
maxscale_shutdown();
}
static void shutdown_service(DCB *dcb, SERVICE *service);
static void shutdown_monitor(DCB *dcb, MONITOR *monitor);