Skip to content

Instantly share code, notes, and snippets.

@R-omk
Created Jan 24, 2020
Embed
What would you like to do?
Print output from tarantool to stdout
#!/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)
@R-omk
Copy link
Author

R-omk commented Jan 24, 2020

my example of usage:

Makefile

replication:
	docker exec -it $(SOME_CONTAINER) tnteval "box.info.replication"

@Totktonada
Copy link

Totktonada commented Jul 10, 2020

Built-in alternative:

$ echo 'box.info.replication' | tarantoolctl enter <instance_name>
$ echo 'box.info.replication' | tarantoolctl connect <console_port / listen_port>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment