日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

在CentOS 6.9 x86_64上玩转OpenResty 1.13.6.1中的resty-cli模块

發(fā)布時(shí)間:2023/11/27 生活经验 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 在CentOS 6.9 x86_64上玩转OpenResty 1.13.6.1中的resty-cli模块 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

resty-cli是OpenResty中命令行工具的集合,其中resty工具是最有用的。

安裝好OpenResty之后,resty-cli就會默認(rèn)安裝,以我的安裝為例,參見博文

http://blog.csdn.net/tao_627/article/details/78912545

它的位置在/opt/openresty/bin下面



前提條件

OpenResty 1.7.7.2+


配置環(huán)境變量

vim /etc/profile

將末尾添加進(jìn)目錄/opt/openresty/bin

export PATH=/opt/openresty/nginx/sbin:/opt/openresty/bin:$PATH

保存退出,然后運(yùn)行下面的命令生效

source /etc/profile

執(zhí)行下面的命令檢查

echo $PATH



安裝依賴庫

yum -y install perl-Time-HiRes

原因參見博文

http://blog.csdn.net/tao_627/article/details/78919286
然后我們可以查看resty的路徑和版本號

resty -h

resty -v




業(yè)務(wù)需求
通常我們驗(yàn)證nginx_lua中的腳本,或者調(diào)試lua相關(guān)代碼片段,或者了解ngx.md5之類函數(shù)的用法等,只能通過加入nginx.conf中的配置,在nginx框架上玩。
但是這未免比較不便,如果我們有一個(gè)命令行工具類似lua, luajit, python等直接執(zhí)行該多好啊。那么這里的resty就是你想要的工具。

測試樣例

下面的幾個(gè)例子都是來自resty-cli模塊的官網(wǎng)

resty -e 'print("hello world")'

time resty -e 'ngx.sleep(3) print("done\n")'

resty -e 'ngx.say(ngx.md5("hello"))'

resty -e 'io.stderr:write("hello world\n")' > /dev/null


更深入的例子及高深玩法有待后續(xù)繼續(xù)挖掘

resty -e 'print("got: ", io.stdin:read("*l"))'


其中taoyunxing是我從鍵盤輸入的內(nèi)容。

time resty -e 'local ths = {}
? ? ? ? ? ? ? ? ?for i = 1, 3 do
? ? ? ? ? ? ? ? ? ? ?ths[i] = ngx.thread.spawn(function ()
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ngx.sleep(3) ngx.say("done ", i)
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? end)
? ? ? ? ? ? ? ? ?end
? ? ? ? ? ? ? ? ?for i = 1, #ths do ngx.thread.wait(ths[i]) end'


resty --shdict='dogs 1m' -e 'local dict = ngx.shared.dogsdict:set("Tom", 56)print(dict:get("Tom"))'



參考文獻(xiàn)

[1].https://openresty.org/cn/resty-cli.html

[2].https://github.com/openresty/resty-cli#readme

[3].

總結(jié)

以上是生活随笔為你收集整理的在CentOS 6.9 x86_64上玩转OpenResty 1.13.6.1中的resty-cli模块的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。