Skip to content
Snippets Groups Projects
Commit 67953d85 authored by Konstantin Osipov's avatar Konstantin Osipov
Browse files

feature-script_dir: review fixes

parent ec89190f
No related branches found
No related tags found
No related merge requests found
...@@ -48,7 +48,6 @@ ...@@ -48,7 +48,6 @@
/** tarantool start-up file */ /** tarantool start-up file */
#define TARANTOOL_LUA_INIT_SCRIPT "init.lua" #define TARANTOOL_LUA_INIT_SCRIPT "init.lua"
struct tarantool_cfg cfg;
struct lua_State *tarantool_L; struct lua_State *tarantool_L;
/* Remember the output of the administrative console in the /* Remember the output of the administrative console in the
...@@ -1082,36 +1081,32 @@ static void ...@@ -1082,36 +1081,32 @@ static void
load_init_script(void *L_ptr) load_init_script(void *L_ptr)
{ {
struct lua_State *L = (struct lua_State *) L_ptr; struct lua_State *L = (struct lua_State *) L_ptr;
struct stat st;
char path[PATH_MAX]; char path[PATH_MAX + 1];
snprintf(path, sizeof(path), "%s/%s", snprintf(path, PATH_MAX, "%s/%s",
((cfg.script_dir) ? cfg.script_dir : "."), cfg.script_dir, TARANTOOL_LUA_INIT_SCRIPT);
TARANTOOL_LUA_INIT_SCRIPT);
say_info("trying to load %s", path);
/* checking that Lua start-up file exist. */ if (access(path, F_OK) == 0) {
if (stat(path, &st)) { say_info("loading %s", path);
/* /* Execute the init file. */
* File doesn't exist. It's OK, tarantool may not have if (tarantool_lua_dofile(L, path))
* start-up file. panic("%s", lua_tostring(L, -1));
*/
return;
} }
/*
/* execute start-up file */ * The file doesn't exist. It's OK, tarantool may
if (tarantool_lua_dofile(L, path)) * have no init file.
panic("%s", lua_tostring(L, -1)); */
} }
void tarantool_lua_load_init_script(struct lua_State *L) void tarantool_lua_load_init_script(struct lua_State *L)
{ {
/* /*
* init script can call box.fiber.yield (including implicitly via * init script can call box.fiber.yield (including implicitly via
* box.insert, box.update, etc...) but yield which called in sched * box.insert, box.update, etc...) but box.fiber.yield() today,
* fiber will crash the server. That why, to avoid the problem, we must * when called from 'sched' fiber crashes the server.
* run init script in to separate fiber. * To work this problem around we must run init script in
* a separate fiber.
*/ */
struct fiber *loader = fiber_create(TARANTOOL_LUA_INIT_SCRIPT, -1, struct fiber *loader = fiber_create(TARANTOOL_LUA_INIT_SCRIPT, -1,
load_init_script, L); load_init_script, L);
......
...@@ -212,3 +212,40 @@ tarantool_box -c tarantool_bad_type.cfg ...@@ -212,3 +212,40 @@ tarantool_box -c tarantool_bad_type.cfg
tarantool_box: can't load config: tarantool_box: can't load config:
- (space = 0 fieldno = 0) index field type mismatch - (space = 0 fieldno = 0) index field type mismatch
lua print_config()
---
io_collect_interval = 0
pid_file = box.pid
slab_alloc_minimal = 64
primary_port = 33013
log_level = 4
logger_nonblock = true
memcached_expire_per_loop = 1024
snap_dir = .
coredump = false
panic_on_snap_error = true
memcached_expire_full_sweep = 3600
replication_port = 0
wal_fsync_delay = 0
too_long_threshold = 0.5
slab_alloc_factor = 2
admin_port = 33015
logger = cat - >> tarantool.log
snap_io_rate_limit = 0
wal_writer_inbox_size = 16384
memcached_expire = false
backlog = 1024
memcached_space = 23
memcached_port = 0
rows_per_wal = 50
wal_mode = fsync_delay
local_hot_standby = false
secondary_port = 33014
panic_on_wal_error = false
script_dir = script_dir
wal_dir = .
bind_ipaddr = INADDR_ANY
readahead = 16320
slab_alloc_arena = 0.1
wal_dir_rescan_delay = 0.1
...
...@@ -63,17 +63,19 @@ sys.stdout.push_filter("(/\S+)+/tarantool", "tarantool") ...@@ -63,17 +63,19 @@ sys.stdout.push_filter("(/\S+)+/tarantool", "tarantool")
server.test_option("-c " + os.path.join(os.getcwd(), "box/tarantool_bad_type.cfg")) server.test_option("-c " + os.path.join(os.getcwd(), "box/tarantool_bad_type.cfg"))
sys.stdout.pop_filter() sys.stdout.pop_filter()
# restore default server
server.stop()
server.deploy(self.suite_ini["config"])
script_dir_path = os.path.join(vardir, "script_dir") script_dir_path = os.path.join(vardir, "script_dir")
os.mkdir(script_dir_path) os.mkdir(script_dir_path)
open(os.path.join(script_dir_path, "init.lua"), "w+").close() shutil.copy("box/test_init.lua", os.path.join(script_dir_path, "init.lua"))
server.stop() server.stop()
server.deploy("box/tarantool_scriptdir.cfg") server.deploy("box/tarantool_scriptdir.cfg")
exec admin "lua print_config()"
# restore default server
server.stop()
shutil.rmtree(script_dir_path, True) shutil.rmtree(script_dir_path, True)
server.deploy(self.suite_ini["config"])
# vim: syntax=python # vim: syntax=python
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment