正在显示
7 个修改的文件
包含
53 行增加
和
3 行删除
| @@ -343,6 +343,7 @@ Remark: | @@ -343,6 +343,7 @@ Remark: | ||
| 343 | 343 | ||
| 344 | ## History | 344 | ## History |
| 345 | 345 | ||
| 346 | +* v2.0, 2016-09-23, support asprocess for oryx. 2.0.218 | ||
| 346 | * v2.0, 2016-09-23, support change work_dir for oryx. | 347 | * v2.0, 2016-09-23, support change work_dir for oryx. |
| 347 | * v2.0, 2016-09-15, fix #640, typo for rtmp type. 2.0.217 | 348 | * v2.0, 2016-09-15, fix #640, typo for rtmp type. 2.0.217 |
| 348 | * v2.0, 2016-09-12, fix fast stream error bug. 2.0.216 | 349 | * v2.0, 2016-09-12, fix fast stream error bug. 2.0.216 |
| @@ -55,6 +55,13 @@ utc_time off; | @@ -55,6 +55,13 @@ utc_time off; | ||
| 55 | # @reamrk do not support reload. | 55 | # @reamrk do not support reload. |
| 56 | # default: ./ | 56 | # default: ./ |
| 57 | work_dir ./; | 57 | work_dir ./; |
| 58 | +# whether quit when parent process changed, | ||
| 59 | +# used for supervisor mode(not daemon), srs should always quit when | ||
| 60 | +# supervisor process exited. | ||
| 61 | +# @remark conflict with daemon, error when both daemon and asprocess are on. | ||
| 62 | +# @reamrk do not support reload. | ||
| 63 | +# default: off | ||
| 64 | +asprocess off; | ||
| 58 | 65 | ||
| 59 | ############################################################################################# | 66 | ############################################################################################# |
| 60 | # heartbeat/stats sections | 67 | # heartbeat/stats sections |
| @@ -1567,7 +1567,7 @@ int SrsConfig::check_config() | @@ -1567,7 +1567,7 @@ int SrsConfig::check_config() | ||
| 1567 | && n != "max_connections" && n != "daemon" && n != "heartbeat" | 1567 | && n != "max_connections" && n != "daemon" && n != "heartbeat" |
| 1568 | && n != "http_api" && n != "stats" && n != "vhost" && n != "pithy_print_ms" | 1568 | && n != "http_api" && n != "stats" && n != "vhost" && n != "pithy_print_ms" |
| 1569 | && n != "http_stream" && n != "http_server" && n != "stream_caster" | 1569 | && n != "http_stream" && n != "http_server" && n != "stream_caster" |
| 1570 | - && n != "utc_time" && n != "work_dir" | 1570 | + && n != "utc_time" && n != "work_dir" && n != "asprocess" |
| 1571 | ) { | 1571 | ) { |
| 1572 | ret = ERROR_SYSTEM_CONFIG_INVALID; | 1572 | ret = ERROR_SYSTEM_CONFIG_INVALID; |
| 1573 | srs_error("unsupported directive %s, ret=%d", n.c_str(), ret); | 1573 | srs_error("unsupported directive %s, ret=%d", n.c_str(), ret); |
| @@ -2055,6 +2055,13 @@ int SrsConfig::check_config() | @@ -2055,6 +2055,13 @@ int SrsConfig::check_config() | ||
| 2055 | // TODO: FIXME: required http server when hls storage is ram or both. | 2055 | // TODO: FIXME: required http server when hls storage is ram or both. |
| 2056 | } | 2056 | } |
| 2057 | 2057 | ||
| 2058 | + // asprocess conflict with daemon | ||
| 2059 | + if (get_asprocess() && get_deamon()) { | ||
| 2060 | + ret = ERROR_SYSTEM_CONFIG_INVALID; | ||
| 2061 | + srs_error("daemon conflict with asprocess, ret=%d", ret); | ||
| 2062 | + return ret; | ||
| 2063 | + } | ||
| 2064 | + | ||
| 2058 | return ret; | 2065 | return ret; |
| 2059 | } | 2066 | } |
| 2060 | 2067 | ||
| @@ -2183,6 +2190,18 @@ string SrsConfig::get_work_dir() { | @@ -2183,6 +2190,18 @@ string SrsConfig::get_work_dir() { | ||
| 2183 | return conf->arg0(); | 2190 | return conf->arg0(); |
| 2184 | } | 2191 | } |
| 2185 | 2192 | ||
| 2193 | +bool SrsConfig::get_asprocess() | ||
| 2194 | +{ | ||
| 2195 | + static bool DEFAULT = false; | ||
| 2196 | + | ||
| 2197 | + SrsConfDirective* conf = root->get("asprocess"); | ||
| 2198 | + if (!conf || conf->arg0().empty()) { | ||
| 2199 | + return DEFAULT; | ||
| 2200 | + } | ||
| 2201 | + | ||
| 2202 | + return SRS_CONF_PERFER_FALSE(conf->arg0()); | ||
| 2203 | +} | ||
| 2204 | + | ||
| 2186 | vector<SrsConfDirective*> SrsConfig::get_stream_casters() | 2205 | vector<SrsConfDirective*> SrsConfig::get_stream_casters() |
| 2187 | { | 2206 | { |
| 2188 | srs_assert(root); | 2207 | srs_assert(root); |
| @@ -379,6 +379,8 @@ public: | @@ -379,6 +379,8 @@ public: | ||
| 379 | * ignore if empty string. | 379 | * ignore if empty string. |
| 380 | */ | 380 | */ |
| 381 | virtual std::string get_work_dir(); | 381 | virtual std::string get_work_dir(); |
| 382 | + // whether use asprocess mode. | ||
| 383 | + virtual bool get_asprocess(); | ||
| 382 | // stream_caster section | 384 | // stream_caster section |
| 383 | public: | 385 | public: |
| 384 | /** | 386 | /** |
| @@ -488,6 +488,7 @@ SrsServer::SrsServer() | @@ -488,6 +488,7 @@ SrsServer::SrsServer() | ||
| 488 | signal_manager = NULL; | 488 | signal_manager = NULL; |
| 489 | 489 | ||
| 490 | handler = NULL; | 490 | handler = NULL; |
| 491 | + ppid = -1; | ||
| 491 | 492 | ||
| 492 | // donot new object in constructor, | 493 | // donot new object in constructor, |
| 493 | // for some global instance is not ready now, | 494 | // for some global instance is not ready now, |
| @@ -635,7 +636,16 @@ int SrsServer::initialize_st() | @@ -635,7 +636,16 @@ int SrsServer::initialize_st() | ||
| 635 | 636 | ||
| 636 | // set current log id. | 637 | // set current log id. |
| 637 | _srs_context->generate_id(); | 638 | _srs_context->generate_id(); |
| 638 | - srs_trace("server main cid=%d", _srs_context->get_id()); | 639 | + |
| 640 | + // check asprocess. | ||
| 641 | + bool asprocess = _srs_config->get_asprocess(); | ||
| 642 | + if (ppid == 1) { | ||
| 643 | + ret = ERROR_SYSTEM_ASSERT_FAILED; | ||
| 644 | + srs_error("for asprocess, ppid should never be init(1), ret=%d", ret); | ||
| 645 | + return ret; | ||
| 646 | + } | ||
| 647 | + srs_trace("server main cid=%d, pid=%d, ppid=%d, asprocess=%d", | ||
| 648 | + _srs_context->get_id(), ::getpid(), ppid, asprocess); | ||
| 639 | 649 | ||
| 640 | return ret; | 650 | return ret; |
| 641 | } | 651 | } |
| @@ -945,6 +955,9 @@ int SrsServer::do_cycle() | @@ -945,6 +955,9 @@ int SrsServer::do_cycle() | ||
| 945 | max = srs_max(max, SRS_SYS_NETWORK_RTMP_SERVER_RESOLUTION_TIMES); | 955 | max = srs_max(max, SRS_SYS_NETWORK_RTMP_SERVER_RESOLUTION_TIMES); |
| 946 | #endif | 956 | #endif |
| 947 | 957 | ||
| 958 | + // for asprocess. | ||
| 959 | + bool asprocess = _srs_config->get_asprocess(); | ||
| 960 | + | ||
| 948 | // the deamon thread, update the time cache | 961 | // the deamon thread, update the time cache |
| 949 | while (true) { | 962 | while (true) { |
| 950 | if(handler && (ret = handler->on_cycle((int)conns.size())) != ERROR_SUCCESS){ | 963 | if(handler && (ret = handler->on_cycle((int)conns.size())) != ERROR_SUCCESS){ |
| @@ -962,6 +975,12 @@ int SrsServer::do_cycle() | @@ -962,6 +975,12 @@ int SrsServer::do_cycle() | ||
| 962 | for (int i = 0; i < temp_max; i++) { | 975 | for (int i = 0; i < temp_max; i++) { |
| 963 | st_usleep(SRS_SYS_CYCLE_INTERVAL * 1000); | 976 | st_usleep(SRS_SYS_CYCLE_INTERVAL * 1000); |
| 964 | 977 | ||
| 978 | + // asprocess check. | ||
| 979 | + if (asprocess && ::getppid() != ppid) { | ||
| 980 | + srs_warn("asprocess ppid changed from %d to %d", ppid, ::getppid()); | ||
| 981 | + return ret; | ||
| 982 | + } | ||
| 983 | + | ||
| 965 | // gracefully quit for SIGINT or SIGTERM. | 984 | // gracefully quit for SIGINT or SIGTERM. |
| 966 | if (signal_gracefully_quit) { | 985 | if (signal_gracefully_quit) { |
| 967 | srs_trace("cleanup for gracefully terminate."); | 986 | srs_trace("cleanup for gracefully terminate."); |
| @@ -277,6 +277,8 @@ private: | @@ -277,6 +277,8 @@ private: | ||
| 277 | bool signal_reload; | 277 | bool signal_reload; |
| 278 | bool signal_gmc_stop; | 278 | bool signal_gmc_stop; |
| 279 | bool signal_gracefully_quit; | 279 | bool signal_gracefully_quit; |
| 280 | + // parent pid for asprocess. | ||
| 281 | + int ppid; | ||
| 280 | public: | 282 | public: |
| 281 | SrsServer(); | 283 | SrsServer(); |
| 282 | virtual ~SrsServer(); | 284 | virtual ~SrsServer(); |
| @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 31 | // current release version | 31 | // current release version |
| 32 | #define VERSION_MAJOR 2 | 32 | #define VERSION_MAJOR 2 |
| 33 | #define VERSION_MINOR 0 | 33 | #define VERSION_MINOR 0 |
| 34 | -#define VERSION_REVISION 217 | 34 | +#define VERSION_REVISION 218 |
| 35 | 35 | ||
| 36 | // generated by configure, only macros. | 36 | // generated by configure, only macros. |
| 37 | #include <srs_auto_headers.hpp> | 37 | #include <srs_auto_headers.hpp> |
-
请 注册 或 登录 后发表评论