mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
For #1579, define signals for fast/grace quit and upgrade
This commit is contained in:
parent
5be69d290f
commit
f4c7b882c5
3 changed files with 17 additions and 9 deletions
|
@ -395,7 +395,7 @@ srs_error_t SrsSignalManager::start()
|
||||||
sa.sa_handler = SrsSignalManager::sig_catcher;
|
sa.sa_handler = SrsSignalManager::sig_catcher;
|
||||||
sigemptyset(&sa.sa_mask);
|
sigemptyset(&sa.sa_mask);
|
||||||
sa.sa_flags = 0;
|
sa.sa_flags = 0;
|
||||||
sigaction(SRS_SIGNAL_GRACEFULLY_QUIT, &sa, NULL);
|
sigaction(SRS_SIGNAL_FAST_QUIT, &sa, NULL);
|
||||||
|
|
||||||
sa.sa_handler = SrsSignalManager::sig_catcher;
|
sa.sa_handler = SrsSignalManager::sig_catcher;
|
||||||
sigemptyset(&sa.sa_mask);
|
sigemptyset(&sa.sa_mask);
|
||||||
|
@ -407,8 +407,8 @@ srs_error_t SrsSignalManager::start()
|
||||||
sa.sa_flags = 0;
|
sa.sa_flags = 0;
|
||||||
sigaction(SRS_SIGNAL_REOPEN_LOG, &sa, NULL);
|
sigaction(SRS_SIGNAL_REOPEN_LOG, &sa, NULL);
|
||||||
|
|
||||||
srs_trace("signal installed, reload=%d, reopen=%d, grace_quit=%d",
|
srs_trace("signal installed, reload=%d, reopen=%d, fast_quit=%d",
|
||||||
SRS_SIGNAL_RELOAD, SRS_SIGNAL_REOPEN_LOG, SRS_SIGNAL_GRACEFULLY_QUIT);
|
SRS_SIGNAL_RELOAD, SRS_SIGNAL_REOPEN_LOG, SRS_SIGNAL_FAST_QUIT);
|
||||||
|
|
||||||
if ((err = trd->start()) != srs_success) {
|
if ((err = trd->start()) != srs_success) {
|
||||||
return srs_error_wrap(err, "signal manager");
|
return srs_error_wrap(err, "signal manager");
|
||||||
|
@ -863,8 +863,8 @@ void SrsServer::on_signal(int signo)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((signo == SIGINT || signo == SRS_SIGNAL_GRACEFULLY_QUIT) && !signal_gracefully_quit) {
|
if ((signo == SIGINT || signo == SRS_SIGNAL_FAST_QUIT) && !signal_gracefully_quit) {
|
||||||
srs_trace("sig=%d, user terminate program, gracefully quit", signo);
|
srs_trace("sig=%d, user terminate program, fast quit", signo);
|
||||||
signal_gracefully_quit = true;
|
signal_gracefully_quit = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -260,12 +260,13 @@ public:
|
||||||
// The signal manager convert signal to io message,
|
// The signal manager convert signal to io message,
|
||||||
// whatever, we will got the signo like the orignal signal(int signo) handler.
|
// whatever, we will got the signo like the orignal signal(int signo) handler.
|
||||||
// @param signo the signal number from user, where:
|
// @param signo the signal number from user, where:
|
||||||
// SRS_SIGNAL_GRACEFULLY_QUIT, the SIGTERM, dispose then quit.
|
// SRS_SIGNAL_FAST_QUIT, the SIGTERM, do essential dispose then quit.
|
||||||
|
// SRS_SIGNAL_GRACEFULLY_QUIT, the SIGQUIT, do careful dispose then quit.
|
||||||
// SRS_SIGNAL_REOPEN_LOG, the SIGUSR1, reopen the log file.
|
// SRS_SIGNAL_REOPEN_LOG, the SIGUSR1, reopen the log file.
|
||||||
// SRS_SIGNAL_RELOAD, the SIGHUP, reload the config.
|
// SRS_SIGNAL_RELOAD, the SIGHUP, reload the config.
|
||||||
// SRS_SIGNAL_PERSISTENCE_CONFIG, application level signal, persistence config to file.
|
// SRS_SIGNAL_PERSISTENCE_CONFIG, application level signal, persistence config to file.
|
||||||
// @remark, for SIGINT:
|
// @remark, for SIGINT:
|
||||||
// no gmc, directly exit.
|
// no gmc, fast quit, do essential dispose then quit.
|
||||||
// for gmc, set the variable signal_gmc_stop, the cycle will return and cleanup for gmc.
|
// for gmc, set the variable signal_gmc_stop, the cycle will return and cleanup for gmc.
|
||||||
// @remark, maybe the HTTP RAW API will trigger the on_signal() also.
|
// @remark, maybe the HTTP RAW API will trigger the on_signal() also.
|
||||||
virtual void on_signal(int signo);
|
virtual void on_signal(int signo);
|
||||||
|
|
|
@ -124,8 +124,15 @@
|
||||||
#define SRS_SIGNAL_RELOAD SIGHUP
|
#define SRS_SIGNAL_RELOAD SIGHUP
|
||||||
// Reopen the log file.
|
// Reopen the log file.
|
||||||
#define SRS_SIGNAL_REOPEN_LOG SIGUSR1
|
#define SRS_SIGNAL_REOPEN_LOG SIGUSR1
|
||||||
// The signal for srs to gracefully quit, do dispose then exit.
|
// For gracefully upgrade, start new SRS and gracefully quit old one.
|
||||||
#define SRS_SIGNAL_GRACEFULLY_QUIT SIGTERM
|
// @see https://github.com/ossrs/srs/issues/1579
|
||||||
|
// TODO: Not implemented.
|
||||||
|
#define SRS_SIGNAL_UPGRADE SIGUSR2
|
||||||
|
// The signal for srs to fast quit, do essential dispose then exit.
|
||||||
|
#define SRS_SIGNAL_FAST_QUIT SIGTERM
|
||||||
|
// The signal for srs to gracefully quit, do carefully dispose then exit.
|
||||||
|
// TODO: FIXME: Not implemented.
|
||||||
|
#define SRS_SIGNAL_GRACEFULLY_QUIT SIGQUIT
|
||||||
|
|
||||||
// The application level signals.
|
// The application level signals.
|
||||||
// Persistence the config in memory to config file.
|
// Persistence the config in memory to config file.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue