mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
for #319, when reload the listen, restart all ingesters.
This commit is contained in:
parent
310b5a14cb
commit
342483bf04
2 changed files with 37 additions and 2 deletions
|
@ -106,6 +106,8 @@ SrsIngester::SrsIngester()
|
||||||
{
|
{
|
||||||
_srs_config->subscribe(this);
|
_srs_config->subscribe(this);
|
||||||
|
|
||||||
|
expired = false;
|
||||||
|
|
||||||
pthread = new SrsReusableThread("ingest", this, SRS_AUTO_INGESTER_SLEEP_US);
|
pthread = new SrsReusableThread("ingest", this, SRS_AUTO_INGESTER_SLEEP_US);
|
||||||
pprint = SrsPithyPrint::create_ingester();
|
pprint = SrsPithyPrint::create_ingester();
|
||||||
}
|
}
|
||||||
|
@ -222,9 +224,8 @@ int SrsIngester::parse_engines(SrsConfDirective* vhost, SrsConfDirective* ingest
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SrsIngester::dispose()
|
void SrsIngester::fast_stop()
|
||||||
{
|
{
|
||||||
// first, use fast stop to notice all FFMPEG to quit gracefully.
|
|
||||||
std::vector<SrsIngesterFFMPEG*>::iterator it;
|
std::vector<SrsIngesterFFMPEG*>::iterator it;
|
||||||
for (it = ingesters.begin(); it != ingesters.end(); ++it) {
|
for (it = ingesters.begin(); it != ingesters.end(); ++it) {
|
||||||
SrsIngesterFFMPEG* ingester = *it;
|
SrsIngesterFFMPEG* ingester = *it;
|
||||||
|
@ -234,6 +235,12 @@ void SrsIngester::dispose()
|
||||||
if (!ingesters.empty()) {
|
if (!ingesters.empty()) {
|
||||||
srs_trace("fast stop all ingesters ok.");
|
srs_trace("fast stop all ingesters ok.");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SrsIngester::dispose()
|
||||||
|
{
|
||||||
|
// first, use fast stop to notice all FFMPEG to quit gracefully.
|
||||||
|
fast_stop();
|
||||||
|
|
||||||
// then, use stop to wait FFMPEG quit one by one and send SIGKILL if needed.
|
// then, use stop to wait FFMPEG quit one by one and send SIGKILL if needed.
|
||||||
stop();
|
stop();
|
||||||
|
@ -249,6 +256,21 @@ int SrsIngester::cycle()
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
|
// when expired, restart all ingesters.
|
||||||
|
if (expired) {
|
||||||
|
expired = false;
|
||||||
|
|
||||||
|
// stop current ingesters.
|
||||||
|
fast_stop();
|
||||||
|
clear_engines();
|
||||||
|
|
||||||
|
// re-prase the ingesters.
|
||||||
|
if ((ret = parse()) != ERROR_SUCCESS) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// cycle exists ingesters.
|
||||||
std::vector<SrsIngesterFFMPEG*>::iterator it;
|
std::vector<SrsIngesterFFMPEG*>::iterator it;
|
||||||
for (it = ingesters.begin(); it != ingesters.end(); ++it) {
|
for (it = ingesters.begin(); it != ingesters.end(); ++it) {
|
||||||
SrsIngesterFFMPEG* ingester = *it;
|
SrsIngesterFFMPEG* ingester = *it;
|
||||||
|
@ -551,5 +573,11 @@ int SrsIngester::on_reload_ingest_updated(string vhost, string ingest_id)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int SrsIngester::on_reload_listen()
|
||||||
|
{
|
||||||
|
expired = true;
|
||||||
|
return ERROR_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -81,6 +81,10 @@ private:
|
||||||
private:
|
private:
|
||||||
SrsReusableThread* pthread;
|
SrsReusableThread* pthread;
|
||||||
SrsPithyPrint* pprint;
|
SrsPithyPrint* pprint;
|
||||||
|
// whether the ingesters are expired,
|
||||||
|
// for example, the listen port changed,
|
||||||
|
// all ingesters must be restart.
|
||||||
|
bool expired;
|
||||||
public:
|
public:
|
||||||
SrsIngester();
|
SrsIngester();
|
||||||
virtual ~SrsIngester();
|
virtual ~SrsIngester();
|
||||||
|
@ -89,6 +93,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual int start();
|
virtual int start();
|
||||||
virtual void stop();
|
virtual void stop();
|
||||||
|
private:
|
||||||
|
virtual void fast_stop();
|
||||||
// interface ISrsReusableThreadHandler.
|
// interface ISrsReusableThreadHandler.
|
||||||
public:
|
public:
|
||||||
virtual int cycle();
|
virtual int cycle();
|
||||||
|
@ -107,6 +113,7 @@ public:
|
||||||
virtual int on_reload_ingest_removed(std::string vhost, std::string ingest_id);
|
virtual int on_reload_ingest_removed(std::string vhost, std::string ingest_id);
|
||||||
virtual int on_reload_ingest_added(std::string vhost, std::string ingest_id);
|
virtual int on_reload_ingest_added(std::string vhost, std::string ingest_id);
|
||||||
virtual int on_reload_ingest_updated(std::string vhost, std::string ingest_id);
|
virtual int on_reload_ingest_updated(std::string vhost, std::string ingest_id);
|
||||||
|
virtual int on_reload_listen();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue