-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.lua
executable file
·73 lines (62 loc) · 2.37 KB
/
init.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env tarantool
require('strict').on()
-- configure path so that you can run application
-- from outside the root directory
if package.setsearchroot ~= nil then
package.setsearchroot()
else
-- Workaround for rocks loading in tarantool 1.10
-- It can be removed in tarantool > 2.2
-- By default, when you do require('mymodule'), tarantool looks into
-- the current working directory and whatever is specified in
-- package.path and package.cpath. If you run your app while in the
-- root directory of that app, everything goes fine, but if you try to
-- start your app with "tarantool myapp/init.lua", it will fail to load
-- its modules, and modules from myapp/.rocks.
local fio = require('fio')
local app_dir = fio.abspath(fio.dirname(arg[0]))
package.path = app_dir .. '/?.lua;' .. package.path
package.path = app_dir .. '/?/init.lua;' .. package.path
package.path = app_dir .. '/.rocks/share/tarantool/?.lua;' .. package.path
package.path = app_dir .. '/.rocks/share/tarantool/?/init.lua;' .. package.path
package.cpath = app_dir .. '/?.so;' .. package.cpath
package.cpath = app_dir .. '/?.dylib;' .. package.cpath
package.cpath = app_dir .. '/.rocks/lib/tarantool/?.so;' .. package.cpath
package.cpath = app_dir .. '/.rocks/lib/tarantool/?.dylib;' .. package.cpath
end
-- params from env
local memtx_memory = tonumber(os.getenv("TARANTOOL_MEMTX_MEMORY")) or (128 * 1024 * 1024)
-- configure cartridge
local cartridge = require('cartridge')
-- https://www.tarantool.io/en/doc/latest/book/cartridge/cartridge_api/modules/cartridge/#cartridge-cfg
local ok, err = cartridge.cfg({
bucket_count = 30000,
roles = {
'cartridge.roles.vshard-storage',
'cartridge.roles.vshard-router',
'cartridge.roles.metrics',
'app.roles.key-value',
'app.roles.storage',
'app.roles.expiry-entries',
}
}, {
memtx_memory = memtx_memory,
replication_synchro_quorum = 2,
memtx_use_mvcc_engine = true,
election_mode = 'candidate'
})
assert(ok, tostring(err))
-- register admin function to use it with 'cartridge admin' command
local admin = require('app.admin')
admin.init()
local metrics = require('cartridge.roles.metrics')
metrics.set_export({
{
path = '/metrics',
format = 'prometheus'
},
{
path = '/health',
format = 'health'
}
})