Play Openresty 1.13.6.1 resty-cli module on CentOS 6.9 x86_64

Source: Internet
Author: User
Tags lua md5 sleep centos install perl

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

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.