|
| 1 | +-- configure path so that you can run application |
| 2 | +-- from outside the root directory |
| 3 | +if package.setsearchroot ~= nil then |
| 4 | + package.setsearchroot() |
| 5 | +else |
| 6 | + -- Workaround for rocks loading in tarantool 1.10 |
| 7 | + -- It can be removed in tarantool > 2.2 |
| 8 | + -- By default, when you do require('mymodule'), tarantool looks into |
| 9 | + -- the current working directory and whatever is specified in |
| 10 | + -- package.path and package.cpath. If you run your app while in the |
| 11 | + -- root directory of that app, everything goes fine, but if you try to |
| 12 | + -- start your app with "tarantool myapp/init.lua", it will fail to load |
| 13 | + -- its modules, and modules from myapp/.rocks. |
| 14 | + local fio = require('fio') |
| 15 | + local app_dir = fio.abspath(fio.dirname(arg[0])) |
| 16 | + package.path = app_dir .. '/?.lua;' .. package.path |
| 17 | + package.path = app_dir .. '/?/init.lua;' .. package.path |
| 18 | + package.path = app_dir .. '/.rocks/share/tarantool/?.lua;' .. package.path |
| 19 | + package.path = app_dir .. '/.rocks/share/tarantool/?/init.lua;' .. package.path |
| 20 | + package.cpath = app_dir .. '/?.so;' .. package.cpath |
| 21 | + package.cpath = app_dir .. '/?.dylib;' .. package.cpath |
| 22 | + package.cpath = app_dir .. '/.rocks/lib/tarantool/?.so;' .. package.cpath |
| 23 | + package.cpath = app_dir .. '/.rocks/lib/tarantool/?.dylib;' .. package.cpath |
| 24 | +end |
| 25 | + |
1 | 26 | local queue = require('queue')
|
2 | 27 | rawset(_G, 'queue', queue)
|
3 | 28 |
|
|
0 commit comments