-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin.lua
39 lines (31 loc) · 1000 Bytes
/
admin.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
local cli_admin = require('cartridge-cli-extensions.admin')
-- register admin function probe to use it with "cartridge admin"
local function init()
cli_admin.init()
local probe = {
usage = 'Probe instance',
args = {
uri = {
type = 'string',
usage = 'Instance URI',
},
},
call = function(opts)
opts = opts or {}
if opts.uri == nil then
return nil, "Please, pass instance URI via --uri flag"
end
local cartridge_admin = require('cartridge.admin')
local ok, err = cartridge_admin.probe_server(opts.uri)
if not ok then
return nil, err.err
end
return {
string.format('Probe %q: OK', opts.uri),
}
end,
}
local ok, err = cli_admin.register('probe', probe.usage, probe.args, probe.call)
assert(ok, err)
end
return {init = init}