• Stars
    star
    176
  • Rank 212,003 (Top 5 %)
  • Language
    Lua
  • License
    MIT License
  • Created almost 8 years ago
  • Updated almost 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Interactive console (REPL) for Openresty and luajit code

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.

More Repositories

1

ruby-fcgi

This is a fork of ruby-fcgi library, but compatible with ruby1.9.1
Ruby
15
star
2

lua-resty-newrelic

This Lua library is a luajit ffi-based wrapper around newrelic agent SDK for the ngx_lua nginx module
Lua
13
star
3

mass_assignment_with_multiple_roles

This gem allows you to pass multiple roles into methods like save and update_attributes
Ruby
6
star
4

acts_as_describable

ActsAsDescribable plugin
Ruby
5
star
5

.vim

my .vim directory files
Vim Script
4
star
6

hb

Python
2
star
7

form_validator

Django form validators for Rails
Ruby
2
star
8

gpicker.vim

gpicker plugin for vim. This is a form of https://github.com/alk/gpicker plugin for vim
Vim Script
2
star
9

counter_finder

Firefox extension to find web counters on the page and view it's statistics
JavaScript
2
star
10

radiant-sape-extention

simple radiant extention to manage links from sape.ru
Ruby
1
star
11

Prototype-simulate

Prototype based helper library for simulating mouse and keyboard events.
Ruby
1
star
12

docker-google-cloud-sdk

1
star
13

ooffice

Pretty simple gem to deal with flat xml templates for OpenOffice
Ruby
1
star
14

docker-maxmind-geoipupdate

1
star
15

exercism-exercises

My version of solutions for http://exercism.io/
Rust
1
star
16

hb_api

JavaScript
1
star
17

test_repo

1
star
18

skyrim-static-mesh-fixes

1
star
19

name_selector

Python
1
star
20

layouts

Ruby
1
star
21

task_board

task board emulation
JavaScript
1
star
22

mernik.monitor

firefox extention for mernik research developers
JavaScript
1
star
23

.oh-my-zsh-custom

Shell
1
star
24

circle_on_github

Addon to add circle CI build info into github PR page
JavaScript
1
star
25

rustybin

CSS
1
star
26

docker-ruby

Shell
1
star