Skip to content

Commit

Permalink
[script] try redis commands via our connector
Browse files Browse the repository at this point in the history
  • Loading branch information
mikz committed Mar 15, 2017
1 parent 4128829 commit 062e4be
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
3 changes: 3 additions & 0 deletions script/redis
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env sh

exec resty -I apicast/src script/redis.lua "$@"
35 changes: 35 additions & 0 deletions script/redis.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env resty -I apicast/src

local cmd = arg[1]
local args = {}

for i=2, #arg do
table.insert(args, arg[i])
end

if not cmd then
print('missing command')
print('usage: ' .. arg[0] .. ' cmd [arg [arg ...]]')
os.exit(1)
end

local inspect = require 'inspect'
local ts = require 'threescale_utils'

local red, err = ts.connect_redis()

if not red and err then
print('could not connect to redis: ', err)
os.exit(1)
end

local fn = red[cmd]
local res, err = fn(red, unpack(args))

if err then
print('error: ', err)
print(inspect(r))
os.exit(1)
end

print(inspect(res))

0 comments on commit 062e4be

Please sign in to comment.