Merge branch 'develop' into MXS-936
This commit is contained in:
@ -44,4 +44,14 @@ void maxscale_reset_starttime(void);
|
|||||||
time_t maxscale_started(void);
|
time_t maxscale_started(void);
|
||||||
int maxscale_uptime(void);
|
int maxscale_uptime(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initiate shutdown of MaxScale.
|
||||||
|
*
|
||||||
|
* This functions informs all threads that they should stop the
|
||||||
|
* processing and exit.
|
||||||
|
*
|
||||||
|
* @return How many times maxscale_shutdown() has been called.
|
||||||
|
*/
|
||||||
|
int maxscale_shutdown(void);
|
||||||
|
|
||||||
MXS_END_DECLS
|
MXS_END_DECLS
|
||||||
|
@ -181,7 +181,6 @@ static int set_user(const char* user);
|
|||||||
bool pid_file_exists();
|
bool pid_file_exists();
|
||||||
void write_child_exit_code(int fd, int code);
|
void write_child_exit_code(int fd, int code);
|
||||||
static bool change_cwd();
|
static bool change_cwd();
|
||||||
void shutdown_server();
|
|
||||||
static void log_exit_status();
|
static void log_exit_status();
|
||||||
static bool daemonize();
|
static bool daemonize();
|
||||||
static bool sniff_configuration(const char* filepath);
|
static bool sniff_configuration(const char* filepath);
|
||||||
@ -288,20 +287,45 @@ static void sigusr1_handler (int i)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const char shutdown_msg[] = "\n\nShutting down MaxScale\n\n";
|
static const char shutdown_msg[] = "\n\nShutting down MaxScale\n\n";
|
||||||
|
static const char patience_msg[] =
|
||||||
|
"\n"
|
||||||
|
"Patience is a virtue...\n"
|
||||||
|
"Shutdown in progress, but one more Ctrl-C or SIGTERM and MaxScale goes down,\n"
|
||||||
|
"no questions asked.\n";
|
||||||
|
|
||||||
static void sigterm_handler(int i)
|
static void sigterm_handler(int i)
|
||||||
{
|
{
|
||||||
last_signal = i;
|
last_signal = i;
|
||||||
shutdown_server();
|
int n_shutdowns = maxscale_shutdown();
|
||||||
write(STDERR_FILENO, shutdown_msg, sizeof(shutdown_msg) - 1);
|
|
||||||
|
if (n_shutdowns == 1)
|
||||||
|
{
|
||||||
|
write(STDERR_FILENO, shutdown_msg, sizeof(shutdown_msg) - 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sigint_handler(int i)
|
sigint_handler(int i)
|
||||||
{
|
{
|
||||||
last_signal = i;
|
last_signal = i;
|
||||||
shutdown_server();
|
int n_shutdowns = maxscale_shutdown();
|
||||||
write(STDERR_FILENO, shutdown_msg, sizeof(shutdown_msg) - 1);
|
|
||||||
|
if (n_shutdowns == 1)
|
||||||
|
{
|
||||||
|
write(STDERR_FILENO, shutdown_msg, sizeof(shutdown_msg) - 1);
|
||||||
|
}
|
||||||
|
else if (n_shutdowns == 2)
|
||||||
|
{
|
||||||
|
write(STDERR_FILENO, patience_msg, sizeof(patience_msg) - 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -2041,14 +2065,22 @@ return_main:
|
|||||||
/*<
|
/*<
|
||||||
* Shutdown MaxScale server
|
* Shutdown MaxScale server
|
||||||
*/
|
*/
|
||||||
void
|
int maxscale_shutdown()
|
||||||
shutdown_server()
|
|
||||||
{
|
{
|
||||||
service_shutdown();
|
static int n_shutdowns = 0;
|
||||||
poll_shutdown();
|
|
||||||
hkshutdown();
|
int n = atomic_add(&n_shutdowns, 1);
|
||||||
memlog_flush_all();
|
|
||||||
log_flush_shutdown();
|
if (n == 0)
|
||||||
|
{
|
||||||
|
service_shutdown();
|
||||||
|
poll_shutdown();
|
||||||
|
hkshutdown();
|
||||||
|
memlog_flush_all();
|
||||||
|
log_flush_shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
return n + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void log_flush_shutdown(void)
|
static void log_flush_shutdown(void)
|
||||||
|
@ -175,8 +175,8 @@ secrets_readKeys(const char* path)
|
|||||||
if (secret_stats.st_mode != (S_IRUSR | S_IFREG))
|
if (secret_stats.st_mode != (S_IRUSR | S_IFREG))
|
||||||
{
|
{
|
||||||
close(fd);
|
close(fd);
|
||||||
MXS_ERROR("Ignoring secrets file "
|
MXS_ERROR("Ignoring secrets file %s, invalid permissions."
|
||||||
"%s, invalid permissions.",
|
"The only permission on the file should be owner:read.",
|
||||||
secret_file);
|
secret_file);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,7 @@
|
|||||||
#include <debugcli.h>
|
#include <debugcli.h>
|
||||||
#include <maxscale/housekeeper.h>
|
#include <maxscale/housekeeper.h>
|
||||||
#include <maxscale/listmanager.h>
|
#include <maxscale/listmanager.h>
|
||||||
|
#include <maxscale/maxscale.h>
|
||||||
|
|
||||||
#include <maxscale/log_manager.h>
|
#include <maxscale/log_manager.h>
|
||||||
#include <sys/syslog.h>
|
#include <sys/syslog.h>
|
||||||
@ -276,7 +277,11 @@ struct subcommand listoptions[] = {
|
|||||||
{0, 0, 0} }
|
{0, 0, 0} }
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void shutdown_server();
|
static void shutdown_server()
|
||||||
|
{
|
||||||
|
maxscale_shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
static void shutdown_service(DCB *dcb, SERVICE *service);
|
static void shutdown_service(DCB *dcb, SERVICE *service);
|
||||||
static void shutdown_monitor(DCB *dcb, MONITOR *monitor);
|
static void shutdown_monitor(DCB *dcb, MONITOR *monitor);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user