使用ZeroBrane Studio調試kong源碼

前置基礎知識:

1、使用ZeroBrane Studio調試Openresty lua腳本請參考:https://blog.csdn.net/zhuankeshumo/article/details/79828080

2、OpenResty api網關設計 https://blog.csdn.net/zhuankeshumo/article/details/79393215

本文主要講解使用ZeroBrane Studio調試kong源碼步驟:

1、切換到kong next分支,並且安裝luarocks,運行luarocks make

2、etc/kong/kong.conf配置lua_package_path和lua_package_cpath


lua_package_path = /home/caozhiyuan/ZeroBraneStudio-1.70/lualibs/?/?.lua;/home/caozhiyuan/ZeroBraneStudio-1.70/lualibs/?.lua;./?.lua;./?/init.lua;  # Sets the Lua module search path
                                           # (LUA_PATH). Useful when developing
                                           # or using custom plugins not stored
                                           # in the default search path.

lua_package_cpath = /home/caozhiyuan/ZeroBraneStudio-1.70/bin/linux/x64/clibs/?.so;            # Sets the Lua C module search path
                                 # (LUA_CPATH).

3、Kong.rewrite() 方法開始添加require('mobdebug').start('127.0.0.1')

4、docker方式安裝kong數據庫POSTGRES(https://docs.konghq.com/install/docker/),運行sudo bin/kong migrations up -c /etc/kong/kong.conf

5、sudo bin/kong start -c /etc/kong/kong.conf --vv

6、參考https://docs.konghq.com/0.14.x/getting-started/configuring-a-service/進行配置,訪問http://localhost:8000/下配置的服務

7、kong源碼理解

(1)、如何保證集羣節點數據一致性?

 db數據變更->workerevents.post_local 刪除本地緩存->cluster_events:broadcast刪除本地緩存

 

 

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