mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
For #1635, inotify watch ConfigMap for reload. 3.0.134
This commit is contained in:
parent
bb509d23e2
commit
856ed5a971
4 changed files with 16 additions and 32 deletions
|
@ -146,7 +146,7 @@ For previous versions, please read:
|
||||||
|
|
||||||
## V3 changes
|
## V3 changes
|
||||||
|
|
||||||
* v3.0, 2020-03-12, For [#1635][bug #1635], inotify watch ConfigMap for reload. 3.0.131
|
* v3.0, 2020-03-12, For [#1635][bug #1635], inotify watch ConfigMap for reload. 3.0.134
|
||||||
* v3.0, 2020-03-12, For [#1635][bug #1635], support auto reaload config by inotify. 3.0.129
|
* v3.0, 2020-03-12, For [#1635][bug #1635], support auto reaload config by inotify. 3.0.129
|
||||||
* v3.0, 2020-03-12, For [#1630][bug #1630], disable cache for stream changing, and drop dup header. 3.0.128
|
* v3.0, 2020-03-12, For [#1630][bug #1630], disable cache for stream changing, and drop dup header. 3.0.128
|
||||||
* v3.0, 2020-03-12, For [#1594][bug #1594], detect and disable daemon for docker. 3.0.127
|
* v3.0, 2020-03-12, For [#1594][bug #1594], detect and disable daemon for docker. 3.0.127
|
||||||
|
|
|
@ -466,7 +466,6 @@ SrsInotifyWorker::SrsInotifyWorker(SrsServer* s)
|
||||||
server = s;
|
server = s;
|
||||||
trd = new SrsSTCoroutine("inotify", this);
|
trd = new SrsSTCoroutine("inotify", this);
|
||||||
inotify_fd = NULL;
|
inotify_fd = NULL;
|
||||||
watch_conf = watch_k8s = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsInotifyWorker::~SrsInotifyWorker()
|
SrsInotifyWorker::~SrsInotifyWorker()
|
||||||
|
@ -539,25 +538,12 @@ srs_error_t SrsInotifyWorker::start()
|
||||||
|
|
||||||
// Watch the config directory events.
|
// Watch the config directory events.
|
||||||
string config_dir = srs_path_dirname(_srs_config->config());
|
string config_dir = srs_path_dirname(_srs_config->config());
|
||||||
if (true) {
|
uint32_t mask = IN_MODIFY | IN_CREATE | IN_MOVED_TO; int watch_conf = 0;
|
||||||
uint32_t mask = IN_ALL_EVENTS;
|
if ((watch_conf = ::inotify_add_watch(fd, config_dir.c_str(), mask)) < 0) {
|
||||||
if ((watch_conf = ::inotify_add_watch(fd, config_dir.c_str(), mask)) < 0) {
|
return srs_error_new(ERROR_INOTIFY_WATCH, "watch file=%s, fd=%d, watch=%d, mask=%#x",
|
||||||
return srs_error_new(ERROR_INOTIFY_WATCH, "watch file=%s, fd=%d, watch=%d, mask=%#x",
|
config_dir.c_str(), fd, watch_conf, mask);
|
||||||
config_dir.c_str(), fd, watch_conf, mask);
|
|
||||||
}
|
|
||||||
srs_trace("auto reload watching fd=%d, watch=%d, file=%s", fd, watch_conf, config_dir.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Watch k8s sub directory.
|
|
||||||
string k8s_file = config_dir + "/..data";
|
|
||||||
if (srs_path_exists(k8s_file)) {
|
|
||||||
uint32_t mask = IN_ALL_EVENTS;
|
|
||||||
if ((watch_k8s = ::inotify_add_watch(fd, k8s_file.c_str(), mask)) < 0) {
|
|
||||||
return srs_error_new(ERROR_INOTIFY_WATCH, "watch file=%s, fd=%d, watch=%d, mask=%#x",
|
|
||||||
k8s_file.c_str(), fd, watch_k8s, mask);
|
|
||||||
}
|
|
||||||
srs_trace("auto reload watching fd=%d, watch=%d, file=%s", fd, watch_k8s, k8s_file.c_str());
|
|
||||||
}
|
}
|
||||||
|
srs_trace("auto reload watching fd=%d, watch=%d, file=%s", fd, watch_conf, config_dir.c_str());
|
||||||
|
|
||||||
if ((err = trd->start()) != srs_success) {
|
if ((err = trd->start()) != srs_success) {
|
||||||
return srs_error_wrap(err, "inotify");
|
return srs_error_wrap(err, "inotify");
|
||||||
|
@ -590,21 +576,21 @@ srs_error_t SrsInotifyWorker::cycle()
|
||||||
for (char* ptr = buf; ptr < buf + nn; ptr += sizeof(inotify_event) + ie->len) {
|
for (char* ptr = buf; ptr < buf + nn; ptr += sizeof(inotify_event) + ie->len) {
|
||||||
ie = (inotify_event*)ptr;
|
ie = (inotify_event*)ptr;
|
||||||
|
|
||||||
//if (!ie->len || !ie->name) {
|
if (!ie->len || !ie->name) {
|
||||||
// continue;
|
continue;
|
||||||
//}
|
}
|
||||||
//
|
|
||||||
//string name = ie->name;
|
string name = ie->name;
|
||||||
//if ((name == k8s_file || name == config_file) && ie->mask & (IN_MODIFY|IN_CREATE)) {
|
if ((name == k8s_file || name == config_file) && ie->mask & (IN_MODIFY|IN_CREATE|IN_MOVED_TO)) {
|
||||||
// do_reload = true;
|
do_reload = true;
|
||||||
//}
|
}
|
||||||
|
|
||||||
srs_trace("inotify event wd=%d, mask=%#x, len=%d, name=%s, reload=%d", ie->wd, ie->mask, ie->len, ie->name, do_reload);
|
srs_trace("inotify event wd=%d, mask=%#x, len=%d, name=%s, reload=%d", ie->wd, ie->mask, ie->len, ie->name, do_reload);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notify server to do reload.
|
// Notify server to do reload.
|
||||||
if (do_reload && srs_path_exists(config_path)) {
|
if (do_reload && srs_path_exists(config_path)) {
|
||||||
//server->on_signal(SRS_SIGNAL_RELOAD);
|
server->on_signal(SRS_SIGNAL_RELOAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_usleep(3000 * SRS_UTIME_MILLISECONDS);
|
srs_usleep(3000 * SRS_UTIME_MILLISECONDS);
|
||||||
|
|
|
@ -192,8 +192,6 @@ private:
|
||||||
SrsServer* server;
|
SrsServer* server;
|
||||||
SrsCoroutine* trd;
|
SrsCoroutine* trd;
|
||||||
srs_netfd_t inotify_fd;
|
srs_netfd_t inotify_fd;
|
||||||
int watch_conf;
|
|
||||||
int watch_k8s;
|
|
||||||
public:
|
public:
|
||||||
SrsInotifyWorker(SrsServer* s);
|
SrsInotifyWorker(SrsServer* s);
|
||||||
virtual ~SrsInotifyWorker();
|
virtual ~SrsInotifyWorker();
|
||||||
|
|
|
@ -24,6 +24,6 @@
|
||||||
#ifndef SRS_CORE_VERSION3_HPP
|
#ifndef SRS_CORE_VERSION3_HPP
|
||||||
#define SRS_CORE_VERSION3_HPP
|
#define SRS_CORE_VERSION3_HPP
|
||||||
|
|
||||||
#define SRS_VERSION3_REVISION 133
|
#define SRS_VERSION3_REVISION 134
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue