<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # 如何對nginx lua module添加新api 本文真正的目的,絕對不是告訴大家如何在nginx lua module添加新api這么點東西。而是以此為例,告訴大家nginx模塊開發環境搭建、碼字編譯、編寫測試用例、代碼提交、申請代碼合并等。給大家順路普及一下git的使用。 目前有個應用場景,需要獲取當前nginx worker數量的需要,所以添加一個新的接口ngx.config.workers()。由于這個功能實現簡單,非常適合大家當做例子。廢話不多說,let's fly now! > 獲取openresty默認安裝包(輔助搭建基礎環境): ~~~ $ wget http://openresty.org/download/ngx_openresty-1.7.10.1.tar.gz $ tar -xvf ngx_openresty-1.7.10.1.tar.gz $ cd ngx_openresty-1.7.10.1 ~~~ > 從github上fork代碼 - 進入[lua-nginx-module](https://github.com/openresty/lua-nginx-module),點擊右側的Fork按鈕 - Fork完畢后,進入自己的項目,點擊 Clone in Desktop 把項目clone到本地 > 預編譯,本步驟參考[這里](http://openresty.com/#Installation): ~~~ $ ./configure $ make ~~~ `注意這里不需要make install` > 修改自己的源碼文件 ~~~ # ngx_lua-0.9.15/src/ngx_http_lua_config.c ~~~ > 編譯變化文件 ~~~ $ rm ./nginx-1.7.10/objs/addon/src/ngx_http_lua_config.o $ make ~~~ # 搭建測試模塊 > 安裝perl cpan [點擊查看](http://www.cnblogs.com/itech/archive/2009/08/10/1542832.html) ~~~ $ cpan cpan[2]> install Test::Nginx::Socket::Lua ~~~ > 書寫測試單元 ~~~ $ cat 131-config-workers.t # vim:set ft= ts=4 sw=4 et fdm=marker: use lib 'lib'; use Test::Nginx::Socket::Lua; #worker_connections(1014); #master_on(); #workers(2); #log_level('warn'); repeat_each(2); #repeat_each(1); plan tests => repeat_each() * (blocks() * 3); #no_diff(); #no_long_string(); run_tests(); __DATA__ === TEST 1: content_by_lua --- config location /lua { content_by_lua ' ngx.say("workers: ", ngx.config.workers()) '; } --- request GET /lua --- response_body_like chop ^workers: 1$ --- no_error_log [error] ~~~ ~~~ $ cat 132-config-workers_5.t # vim:set ft= ts=4 sw=4 et fdm=marker: use lib 'lib'; use Test::Nginx::Socket::Lua; #worker_connections(1014); #master_on(); workers(5); #log_level('warn'); repeat_each(2); #repeat_each(1); plan tests => repeat_each() * (blocks() * 3); #no_diff(); #no_long_string(); run_tests(); __DATA__ === TEST 1: content_by_lua --- config location /lua { content_by_lua ' ngx.say("workers: ", ngx.config.workers()) '; } --- request GET /lua --- response_body_like chop ^workers: 5$ --- no_error_log [error] ~~~ # 單元測試 ~~~ $ export PATH=/path/to/your/nginx/sbin:$PATH #設置nginx查找路徑 $ cd ngx_lua-0.9.15 # 進入你修改的模塊 $ prove t/131-config-workers.t # 測試指定腳本 t/131-config-workers.t .. ok All tests successful. Files=1, Tests=6, 1 wallclock secs ( 0.04 usr 0.00 sys + 0.18 cusr 0.05 csys = 0.27 CPU) Result: PASS $ $ prove t/132-config-workers_5.t # 測試指定腳本 t/132-config-workers_5.t .. ok All tests successful. Files=1, Tests=6, 0 wallclock secs ( 0.03 usr 0.00 sys + 0.17 cusr 0.04 csys = 0.24 CPU) Result: PASS ~~~ # 提交代碼,推動我們的修改被官方合并 - 首先把代碼commit到github - commit成功后,以次點擊github右上角的Pull request -> New pull request - 這時候github會彈出一個自己與官方版本對比結果的頁面,里面包含有我們所有的修改,確定我們的修改都被包含其中,點擊Create pull request按鈕 - 輸入標題、內容(you'd better write in english),點擊Create pull request按鈕 - 提交完成,就可以等待官方作者是否會被采納了(代碼+測試用例,必不可少) 來看看我們的成果吧: pull request : [點擊查看](https://github.com/openresty/lua-nginx-module/pull/531)commit detail: [點擊查看](https://github.com/membphis/lua-nginx-module/commit/9d991677c090e1f86fa5840b19e02e56a4a17f86)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看