1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

support reload pid.

This commit is contained in:
winlin 2014-04-12 20:46:32 +08:00
parent 0a016e58bf
commit f652c28485
5 changed files with 41 additions and 0 deletions

View file

@ -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();
}