Johan Wikman bc1c2e1152 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.
2016-11-10 11:09:59 +02:00

58 lines
1.5 KiB
C

#pragma once
/*
* Copyright (c) 2016 MariaDB Corporation Ab
*
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file and at www.mariadb.com/bsl.
*
* Change Date: 2019-07-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2 or later of the General
* Public License.
*/
/**
* @file maxscale.h
*
* Some general definitions for MaxScale
*
* @verbatim
* Revision History
*
* Date Who Description
* 05/02/14 Mark Riddoch Initial implementation
*
* @endverbatim
*/
#include <maxscale/cdefs.h>
#include <time.h>
MXS_BEGIN_DECLS
/* Exit status for MaxScale */
#define MAXSCALE_SHUTDOWN 0 /* Good shutdown */
#define MAXSCALE_BADCONFIG 1 /* Configuration fiel error */
#define MAXSCALE_NOLIBRARY 2 /* No embedded library found */
#define MAXSCALE_NOSERVICES 3 /* No servics are running */
#define MAXSCALE_ALREADYRUNNING 4 /* MaxScale is already runing */
#define MAXSCALE_BADARG 5 /* Bad command line argument */
#define MAXSCALE_INTERNALERROR 6 /* Internal error, see error log */
void maxscale_reset_starttime(void);
time_t maxscale_started(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