diff --git a/src/tarantool_lua.m b/src/tarantool_lua.m index 0ad42f093e54fe81185e060105beff6f0ef39a52..7759f2045167a5f1698887037fdfa64dcbb9ab21 100644 --- a/src/tarantool_lua.m +++ b/src/tarantool_lua.m @@ -48,7 +48,6 @@ /** tarantool start-up file */ #define TARANTOOL_LUA_INIT_SCRIPT "init.lua" -struct tarantool_cfg cfg; struct lua_State *tarantool_L; /* Remember the output of the administrative console in the @@ -1082,36 +1081,32 @@ static void load_init_script(void *L_ptr) { struct lua_State *L = (struct lua_State *) L_ptr; - struct stat st; - char path[PATH_MAX]; - snprintf(path, sizeof(path), "%s/%s", - ((cfg.script_dir) ? cfg.script_dir : "."), - TARANTOOL_LUA_INIT_SCRIPT); + char path[PATH_MAX + 1]; + snprintf(path, PATH_MAX, "%s/%s", + cfg.script_dir, TARANTOOL_LUA_INIT_SCRIPT); - say_info("trying to load %s", path); - /* checking that Lua start-up file exist. */ - if (stat(path, &st)) { - /* - * File doesn't exist. It's OK, tarantool may not have - * start-up file. - */ - return; + if (access(path, F_OK) == 0) { + say_info("loading %s", path); + /* Execute the init file. */ + if (tarantool_lua_dofile(L, path)) + panic("%s", lua_tostring(L, -1)); } - - /* execute start-up file */ - if (tarantool_lua_dofile(L, path)) - panic("%s", lua_tostring(L, -1)); + /* + * The file doesn't exist. It's OK, tarantool may + * have no init file. + */ } void tarantool_lua_load_init_script(struct lua_State *L) { /* * init script can call box.fiber.yield (including implicitly via - * box.insert, box.update, etc...) but yield which called in sched - * fiber will crash the server. That why, to avoid the problem, we must - * run init script in to separate fiber. + * box.insert, box.update, etc...) but box.fiber.yield() today, + * when called from 'sched' fiber crashes the server. + * To work this problem around we must run init script in + * a separate fiber. */ struct fiber *loader = fiber_create(TARANTOOL_LUA_INIT_SCRIPT, -1, load_init_script, L); diff --git a/test/box/configuration.result b/test/box/configuration.result index b41d419c7d05d3b40646455562d8a2f1cd04128a..e31e09a18b6412e5ad99d4174a6635ce278d4f62 100644 --- a/test/box/configuration.result +++ b/test/box/configuration.result @@ -212,3 +212,40 @@ tarantool_box -c tarantool_bad_type.cfg tarantool_box: can't load config: - (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 +... diff --git a/test/box/configuration.test b/test/box/configuration.test index 2f3da6011c955c6bc6e9ba57f972ea4346207b6f..c3971ae35a03550ed72319fe601e65271af44df9 100644 --- a/test/box/configuration.test +++ b/test/box/configuration.test @@ -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")) sys.stdout.pop_filter() -# restore default server -server.stop() -server.deploy(self.suite_ini["config"]) script_dir_path = os.path.join(vardir, "script_dir") 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.deploy("box/tarantool_scriptdir.cfg") +exec admin "lua print_config()" + +# restore default server +server.stop() shutil.rmtree(script_dir_path, True) +server.deploy(self.suite_ini["config"]) # vim: syntax=python