• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

saks/lua-resty-repl: Interactive console (REPL) for Openresty and luajit code

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

saks/lua-resty-repl

开源软件地址(OpenSource Url):

https://github.com/saks/lua-resty-repl

开源编程语言(OpenSource Language):

Lua 93.8%

开源软件介绍(OpenSource Introduction):

Welcome to Resty Repl

Features

Resty Repl is a powerful alternative to the standard luajit shell ispired by pry. It is written from scratch to provide a number of advanced features, including:

  • Full read/write access to locals, upvalues and global variables
  • Pretty print for objects
  • A Powerful and flexible command system
  • Ability to view and replay history
  • Ability to see a context and source of the place in code from where repl was started
  • Runtime invocation (use Resty Repl as a developer console or debugger)
  • Tab completion
  • Simple and easy way to debug lua running in the nginx (openresty)

Runtime invocation

First install luarock

luarocks install lua-resty-repl

Then just drop this snippet anywhere in your code:

require('resty.repl').start()

or run as cli:

resty-repl

Openresty debugger

But what makes it really nice is that now you can debug your openresty code right from running nginx!

master_process off;
error_log stderr notice;
daemon off;

events {
  worker_connections 1024;
}

http {
  server {
    listen 8080;
    lua_code_cache off;

    location / {
      content_by_lua_block {
        require('resty.repl').start()
      }
    }
  }
}

and start debugging:

$ curl -H X-Header:buz 172.17.0.2:8080?foo=bar
nginx -c /tmp/ngx.conf
2016/09/20 16:26:33 [alert] 2257#0: lua_code_cache is off; this will hurt performance in /tmp/ngx.conf:12
nginx: [alert] lua_code_cache is off; this will hurt performance in /tmp/ngx.conf:12
2016/09/20 16:26:33 [notice] 2257#0: using the "epoll" event method
2016/09/20 16:26:33 [notice] 2257#0: openresty/1.11.2.1
2016/09/20 16:26:33 [notice] 2257#0: built by gcc 4.9.2 (Debian 4.9.2-10)
2016/09/20 16:26:33 [notice] 2257#0: OS: Linux 4.4.0-38-generic
2016/09/20 16:26:33 [notice] 2257#0: getrlimit(RLIMIT_NOFILE): 65536:65536

From: content_by_lua(ngx.conf:17) @ line 2

[1] ngx(content)> ngx.req.get_headers()
=> {
  accept = "*/*",
  host = "172.17.0.2:8080",
  ["user-agent"] = "curl/7.47.0",
  ["x-header"] = "buz",
  <metatable> = {
    __index = <function 1>
  }
}
[2] ngx(content)> ngx.req.get_uri_args()
=> {
  foo = "bar"
}
[3] ngx(content)> ngx.say 'it works!'
=> 1
[4] ngx(content)> ngx.exit(ngx.OK)
172.17.0.1 - - [20/Sep/2016:16:26:50 +0000] "GET /?foo=bar HTTP/1.1" 200 20 "-" "curl/7.47.0"

Compatibility

Right now it's only compatible with:

  • luajit
  • lua5.1 (no readline)

Os Support

  • GNU/Linux
  • Mac OS

Roadmap

  • colorized output
  • smarter completion
  • full readline support for lua (no ffi environments)
  • remote debugger
  • command for showing function source
  • test suite with resty-cli, luajit and different versions of lua
  • better inspect library

Code Status

Build Status

License

resty-repl is released under the MIT License.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
tbastos/vim-lua: Improved Lua 5.3 syntax and indentation support for Vim发布时间:2022-08-16
下一篇:
cloudwu/luaecs发布时间:2022-08-16
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap