Giter Site home page Giter Site logo

lua-resty-repl's 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
  • 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/19 16:39:19 [alert] 639#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/19 16:39:19 [notice] 639#0: using the "epoll" event method
2016/09/19 16:39:19 [notice] 639#0: openresty/1.11.2.1
2016/09/19 16:39:19 [notice] 639#0: built by gcc 4.9.2 (Debian 4.9.2-10)
2016/09/19 16:39:19 [notice] 639#0: OS: Linux 4.4.0-38-generic
2016/09/19 16:39:19 [notice] 639#0: getrlimit(RLIMIT_NOFILE): 65536:65536
[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 - - [19/Sep/2016:16:39:30 +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

Only GNU/Linux for now.

Roadmap

  • colorized output
  • smarter completion
  • full readline support for lua (no ffi environments)
  • remote debugger
  • command for showing function source
  • show context and source of the place in code from where repl was started
  • 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.

lua-resty-repl's People

Contributors

saks avatar

Watchers

James Cloos avatar zhangf avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.