Reloading a module | Tarantool
Check out the new release policy
Application server Reloading a module

Reloading a module

You can reload any Tarantool application or module with zero downtime.

Here’s an example that illustrates the most typical case – “update and reload”.


In this example, we use recommended administration practices based on instance files and tarantoolctl utility.

  1. Update the application file.

    For example, a module in /usr/share/tarantool/app.lua:

    local function start()
      -- initial version
      box.once("myapp:v1.0", function()"somedata")"primary")
      -- migration code from 1.0 to 1.1
      box.once("myapp:v1.1", function()
      -- migration code from 1.1 to 1.2
      box.once("myapp:v1.2", function()
    -- start some background fibers if you need
    local function stop()
      -- stop all background fibers and clean up resources
    local function api_for_call(xxx)
      -- do some business
    return {
      start = start,
      stop = stop,
      api_for_call = api_for_call
  2. Update the instance file.

    For example, /etc/tarantool/instances.enabled/my_app.lua:

    #!/usr/bin/env tarantool
    -- hot code reload example
    box.cfg({listen = 3302})
    -- ATTENTION: unload it all properly!
    local app = package.loaded['app']
    if app ~= nil then
      -- stop the old application version
      -- unload the application
      package.loaded['app'] = nil
      -- unload all dependencies
      package.loaded['somedep'] = nil
    -- load the application'require app')
    app = require('app')
    -- start the application
    app.start({some app options controlled by sysadmins})

    The important thing here is to properly unload the application and its dependencies.

  3. Manually reload the application file.

    For example, using tarantoolctl:

    $ tarantoolctl eval my_app /etc/tarantool/instances.enabled/my_app.lua

After you compiled a new version of a C module (*.so shared library), call box.schema.func.reload(‘module-name’) from your Lua script to reload the module.