Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to see print() results in Tarantool Docker container

Tags:

tarantool

I am using tarantool/tarantool:2.6.0 Docker image (the latest at the moment) and writing lua scripts for the project. I try to find out how to see the results of callin' print() function. It's quite difficult to debug my code without print() working.
In tarantool console print() have no effect also.

Using simple print()

Docs says that print() works to stdout, but I don't see any results when I watch container's logs by docker logs -f <CONTAINER_NAME>

I also tried to set container's logs driver to local. Than I get one time print to container's logs, but only once...

The container's /var/log directory is always empty.

Using box.session.push()

Using box.session.push() works fine in console, but when I use it in lua script:

-- app.lua
function log(s)
  box.session.push(s)
end

-- No effect
log('hello')

function say_something(s)
    log(s)
end

box.schema.func.create('say_something')
box.schema.user.grant('guest', 'execute', 'function', 'say_something')

And then call say_something() from nodeJs connector like this:

const TarantoolConnection = require('tarantool-driver');

const conn = new TarantoolConnection(connectionData);
const res = await conn.call('update_links', 'hello');

I get error: enter image description here

Any suggestions? Thanx!

like image 828
chernetsky Avatar asked Nov 06 '22 04:11

chernetsky


1 Answers

I suppose you've missed io.flush() after print command.

After I added io.flush() after each print call my messages start to write to logs (docker logs -f <CONTAINER_NAME>).

Also I'd recommend to use log module for such purpose. It writes to stderr without buffering.

Regarding the error in the connector, I think nodejs connector simply doesn't support pushes.

like image 168
Oleg Babin Avatar answered Dec 02 '22 12:12

Oleg Babin