Skip to content

Instantly share code, notes, and snippets.

@negasus
Created May 28, 2019 15:51
Show Gist options
  • Save negasus/4ffe264d1fb8ea4d32d99f98a4392008 to your computer and use it in GitHub Desktop.
Save negasus/4ffe264d1fb8ea4d32d99f98a4392008 to your computer and use it in GitHub Desktop.
Tarantool vshard storage isntance file with Reload functions
require('strict').on()
local log = require('log')
vshard = require('vshard')
local cfg = {
listen = '{{ ip }}:{{ item.port }}',
net_msg_max = 10000,
readahead = 1 * 1024 * 1024,
memtx_memory = 2 * 1024 * 1024 * 1024,
vinyl_memory = 4 * 1024 * 1024 * 1024,
vinyl_cache = 1 * 1024 * 1024 * 1024,
vinyl_page_size = 200 * 1024,
wal_mode = "write",
log_level = 5, -- info
bucket_count = 30000,
work_dir = '/var/lib/tarantool',
feedback_enabled = false,
}
cfg.sharding = require('vshard_config')
vshard.storage.cfg(cfg, '{{ item.uuid }}')
box.once("app_sessions:storage:v1", function()
box.schema.user.create('{{ tarantool_sessions_user }}', { password = '{{ tarantool_sessions_password }}', if_not_exists = true })
box.schema.user.grant('{{ tarantool_sessions_user }}', 'read,write,execute', 'universe')
end)
function reload_vshard()
cfg.sharding = require('vshard_config')
vshard.storage.cfg(cfg, '{{ item.uuid }}')
log.info("vshard configuration reloaded")
end
function reload_application()
app = package.loaded['app_sessions_v1.storage']
if app ~= nil then
app.stop()
package.loaded['app_sessions_v1.storage'] = nil
end
app = require('app_sessions_v1.storage')
app.start({ host = "{{ ip }}", port = {{ item.prom_port }} })
log.info("application reloaded")
end
app = require('app_sessions_v1.storage')
app.start({ host = "{{ ip }}", port = {{ item.prom_port }} })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment