In Redis I run a Lua script through CLI like this:-
$ redis-cli --eval debug_script.lua key1 key2 key3 key4 , arg1 arg2
So, my Lua script a
Found some solutions:
Solution 1 )
var redis = require('redis')
var client = redis.createClient()
var fs = require('fs')
client.eval(fs.readFileSync('./debug_script.lua'), 4, key1, key2, key3, key4, arg1, arg2, function(err, res) {
console.log(res);
});
Note: 4
(second argument of eval) represents the number of keys to be passed in the script.
Solution 2) Creates a child process and run CLI command.
var redis = require("redis");
var client = redis.createClient();
var exec = require('child_process').exec;
var cmd = 'redis-cli --eval debug_script.lua key1 key2 key3 key4 , arg1 arg2';
exec(cmd, function(error, stdout, stderr) {
// command output is in stdout
console.log("something happened \n");
console.log(stdout);
});