RESTY-CLI is a collection of command-line tools in Openresty, where resty tools are most useful.
After installing the Openresty, the RESTY-CLI will be installed by default, as an example of my installation, see the blog post
http://blog.csdn.net/tao_627/article/details/78912545
It's located under the/opt/openresty/bin.
Pre-conditions
Openresty 1.7.7.2+
Configuring environment Variables
Vim/etc/profile
Add the end to the directory/opt/openresty/bin
Export Path=/opt/openresty/nginx/sbin:/opt/openresty/bin: $PATH
Save exit, and then run the following command to take effect
Source/etc/profile
Perform the following command check
Echo $PATH
Installing dependent Libraries
Yum-y Install Perl-time-hires
Reasons See blog post
http://blog.csdn.net/tao_627/article/details/78919286
We can then view the path and version number of the Resty
Resty-h
Resty-v
Business requirements
Often we validate scripts in Nginx_lua, or debug LUA-related snippets, or understand the use of functions such as NGX.MD5, only by joining the configuration in nginx.conf to play on the nginx frame.
But it would be inconvenient if we had a command-line tool like Lua, Luajit, Python, and so on to do it just fine. So the resty here is the tool you want.
Test examples
Here are a few examples from the RESTY-CLI module's official website.
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
More in-depth examples and advanced gameplay to continue digging
Resty-e ' Print ("Got:", Io.stdin:read ("*l")) '
Where taoyunxing is what I entered from the keyboard.
Time Resty-e ' local ths = {}
For i = 1, 3 does
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.dogs
dict:set ("Tom", "page")
print (Dict:get ("Tom")) '
Reference Documents
[1].https://openresty.org/cn/resty-cli.html
[2].https://github.com/openresty/resty-cli#readme