mirror of
https://github.com/ossrs/srs.git
synced 2025-02-13 03:41:55 +00:00
support reload pid.
This commit is contained in:
parent
0a016e58bf
commit
f652c28485
5 changed files with 41 additions and 0 deletions
|
@ -505,6 +505,21 @@ int SrsConfig::reload()
|
|||
srs_trace("reload listen success.");
|
||||
}
|
||||
|
||||
// merge config: pid
|
||||
if (!srs_directive_equals(root->get("pid"), old_root->get("pid"))) {
|
||||
for (it = subscribes.begin(); it != subscribes.end(); ++it) {
|
||||
ISrsReloadHandler* subscribe = *it;
|
||||
if ((ret = subscribe->on_reload_pid()) != ERROR_SUCCESS) {
|
||||
srs_error("notify subscribes reload pid failed. ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
srs_trace("reload pid success.");
|
||||
}
|
||||
|
||||
// directly supported for reload:
|
||||
// chunk_size, ff_log_dir
|
||||
|
||||
// merge config: pithy_print
|
||||
if (!srs_directive_equals(root->get("pithy_print"), old_root->get("pithy_print"))) {
|
||||
for (it = subscribes.begin(); it != subscribes.end(); ++it) {
|
||||
|
|
|
@ -40,6 +40,11 @@ int ISrsReloadHandler::on_reload_listen()
|
|||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
int ISrsReloadHandler::on_reload_pid()
|
||||
{
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
int ISrsReloadHandler::on_reload_pithy_print()
|
||||
{
|
||||
return ERROR_SUCCESS;
|
||||
|
|
|
@ -42,6 +42,7 @@ public:
|
|||
virtual ~ISrsReloadHandler();
|
||||
public:
|
||||
virtual int on_reload_listen();
|
||||
virtual int on_reload_pid();
|
||||
virtual int on_reload_pithy_print();
|
||||
virtual int on_reload_vhost_added(std::string vhost);
|
||||
virtual int on_reload_vhost_removed(std::string vhost);
|
||||
|
|
|
@ -159,6 +159,7 @@ SrsServer::SrsServer()
|
|||
{
|
||||
signal_reload = false;
|
||||
signal_gmc_stop = false;
|
||||
pid_fd = -1;
|
||||
|
||||
// donot new object in constructor,
|
||||
// for some global instance is not ready now,
|
||||
|
@ -189,6 +190,11 @@ SrsServer::~SrsServer()
|
|||
|
||||
close_listeners();
|
||||
|
||||
if (pid_fd > 0) {
|
||||
::close(pid_fd);
|
||||
pid_fd = -1;
|
||||
}
|
||||
|
||||
#ifdef SRS_HTTP_API
|
||||
srs_freep(http_api_handler);
|
||||
#endif
|
||||
|
@ -310,6 +316,7 @@ int SrsServer::acquire_pid_file()
|
|||
}
|
||||
|
||||
srs_trace("write pid=%d to %s success!", pid, pid_file.c_str());
|
||||
pid_fd = fd;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -554,3 +561,13 @@ int SrsServer::on_reload_listen()
|
|||
{
|
||||
return listen();
|
||||
}
|
||||
|
||||
int SrsServer::on_reload_pid()
|
||||
{
|
||||
if (pid_fd > 0) {
|
||||
::close(pid_fd);
|
||||
pid_fd = -1;
|
||||
}
|
||||
|
||||
return acquire_pid_file();
|
||||
}
|
||||
|
|
|
@ -88,6 +88,7 @@ private:
|
|||
SrsIngester* ingester;
|
||||
#endif
|
||||
private:
|
||||
int pid_fd;
|
||||
std::vector<SrsConnection*> conns;
|
||||
std::vector<SrsListener*> listeners;
|
||||
bool signal_reload;
|
||||
|
@ -107,8 +108,10 @@ public:
|
|||
private:
|
||||
virtual void close_listeners();
|
||||
virtual int accept_client(SrsListenerType type, st_netfd_t client_stfd);
|
||||
// interface ISrsThreadHandler.
|
||||
public:
|
||||
virtual int on_reload_listen();
|
||||
virtual int on_reload_pid();
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue