Created
January 24, 2020 06:56
-
-
Save R-omk/cfe0f3894064735797ff91be5fe4689f to your computer and use it in GitHub Desktop.
Print output from tarantool to stdout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env tarantool | |
local CONSOLE_SOCKET_PATH = 'unix/:/var/run/tarantool/tarantool.sock' | |
local os = require("os") | |
console = require('console') | |
console.on_start(function(self) | |
local status, reason | |
status, reason = pcall(function() require('console').connect(CONSOLE_SOCKET_PATH) end) | |
if not status then | |
self:print(reason) | |
self.running = false | |
os.exit(1) | |
end | |
local res = self:eval(arg[1]) | |
if res ~= nil then | |
print(res) | |
end | |
os.exit(0) | |
end) | |
console.on_client_disconnect(function(self) self.running = false end) | |
console.start() | |
os.exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Built-in alternative: