nginx rtmp 多進程使用init process注意的地方

    在nginx_rtmp中添加一些功能,需要注意nginx的多進程特性,雖然最新版本的nginxrtmp 模塊支持auto_push模塊
rtmp_auto_push on;
rtmp_auto_push_reconnect 1s;
rtmp_socket_dir /var/sock;

例如我添加每個節點使用啓動後調用其他服務器的http接口,上報節點信息,在init process 中不能直接使用ngx_add_timer,因爲rtmp模塊比ngx_event_core_module 先初始化,而且把不能把ngx_event_core_module模塊的優先級添加在rtmp所有模塊前面,會有autopush 模塊不能使用的問題。

參考exec 和relay中的ngx_post_event(e, &ngx_rtmp_init_queue); 方式延遲調用。

如果只想讓一個進程上報信息,只讓ngx_process_slot ==0 的進程上報就行如下

/* only first worker does static pulling */

if (ngx_process_slot) {
    return NGX_OK;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章