diff --git a/extra/dist/tarantoolctl b/extra/dist/tarantoolctl index 0011525a0c02788d581887d80fc58f36fad962ac..d6c5aca165ba8d69cffc629e6ab7f19158ea7827 100755 --- a/extra/dist/tarantoolctl +++ b/extra/dist/tarantoolctl @@ -495,17 +495,35 @@ elseif cmd == 'status' then print(instance_name .. ' is running (pid:' .. default_cfg.pid_file .. ')') os.exit(0) elseif cmd == 'reload' then - if arg[1] == nil then + local filename = arg[1] + if filename == nil then log.error("Usage: tarantoolctl reload instance_name file.lua") os.exit(1) end - if fio.stat(arg[1]) == nil then + if fio.stat(filename) == nil then if errno() == errno.ENOENT then - print(arg[1] .. ': file not found') + print(filename .. ': file not found') os.exit(1) end end - dofile(arg[1]) + local file = io.open(filename, 'rb') + local content = file:read('*all') + + if fio.stat(console_sock) == nil then + log.warn("pid file exists, but the control socket (%s) doesn't", + console_sock) + os.exit(2) + end + + local s = socket.tcp_connect('unix/', console_sock) + if s == nil then + log.warn("Can't access control socket %s", console_sock) + os.exit(3) + end + s:write("loadstring('" .. content .. "')()\n") + s:close() + + os.exit(0) else log.error("Unknown command '%s'", cmd) os.exit(-1)