diff --git a/src/lua/init.c b/src/lua/init.c index 127e935d7021..7b8a54297514 100644 --- a/src/lua/init.c +++ b/src/lua/init.c @@ -36,6 +36,7 @@ #endif #include +#include #include #include #include @@ -45,6 +46,8 @@ #include "version.h" #include "backtrace.h" #include "coio.h" +#include +#include "cfg.h" #include "lua/fiber.h" #include "lua/fiber_cond.h" #include "lua/fiber_channel.h" @@ -647,6 +650,17 @@ run_script_f(va_list ap) is_a_tty = inj->iparam; }); + /* + int background = 0; + lua_getglobal(L, "box"); + if (lua_isnil(L, -1)) { + lua_getfield(L, -1, "cfg"); + if (lua_istable(L, -1)) { + background = cfg_geti("background"); + } + } + */ + if (path && strcmp(path, "-") != 0 && access(path, F_OK) == 0) { /* Execute script. */ if (luaL_loadfile(L, path) != 0) @@ -659,6 +673,12 @@ run_script_f(va_list ap) goto luajit_error; if (lua_main(L, argc, argv) != 0) goto error; + } else if (is_option_e_ran) { + /* Execute a string passed with option -e */ + if (luaL_loadstring(L, "print()") != 0) + goto luajit_error; + if (lua_main(L, argc, argv) != 0) + goto error; } else if (!is_option_e_ran) { interactive = true; } diff --git a/test/box-tap/gh-5602-environment-cfg-test-cases.lua b/test/box-tap/gh-5602-environment-cfg-test-cases.lua index 72031778bad6..e4ee9f96ffec 100755 --- a/test/box-tap/gh-5602-environment-cfg-test-cases.lua +++ b/test/box-tap/gh-5602-environment-cfg-test-cases.lua @@ -67,5 +67,13 @@ if arg[1] == '5' then end test:is(err_msg, exp_err, 'bad strip_core value') end +if arg[1] == '6' then + test:plan(5) + test:ok(status, 'box.cfg is successful') + test:is(box.cfg['listen'], '3301', 'listen') + test:is(box.cfg['background'], true, 'background') + test:is(box.cfg['pid_file'], 'tarantool.pid', 'pid file') + test:is(box.cfg['log'], 'tarantool.log', 'log file') +end os.exit(test:check() and 0 or 1) diff --git a/test/box-tap/gh-5602-environment-vars-cfg.test.lua b/test/box-tap/gh-5602-environment-vars-cfg.test.lua index be1e402eec4a..0f6680702686 100755 --- a/test/box-tap/gh-5602-environment-vars-cfg.test.lua +++ b/test/box-tap/gh-5602-environment-vars-cfg.test.lua @@ -39,6 +39,11 @@ local cases = { 'TT_BACKGROUND=true TT_VINYL_TIMEOUT=60.1', 'TT_SQL_CACHE_SIZE=a', 'TT_STRIP_CORE=a', + ('%s %s %s %s'):format( + 'TT_LISTEN=3301', + 'TT_LOG=tarantool.log', + 'TT_PID_FILE=tarantool.pid', + 'TT_BACKGROUND=true'), } test:plan(1)