Ejemplo n.º 1
0
def project_with_patched_init(cartridge_cmd, short_tmpdir):
    project = Project(cartridge_cmd, 'patched-project', short_tmpdir, 'cartridge')

    remove_all_dependencies(project)

    patched_init = '''#!/usr/bin/env tarantool
local fiber = require('fiber')
fiber.create(function()
    fiber.sleep(1)
end)

require('log').info('I am starting...')

-- Copied from cartridge.cfg to provide support for NOTIFY_SOCKET in old tarantool
local tnt_version = string.split(_TARANTOOL, '.')
local tnt_major = tonumber(tnt_version[1])
local tnt_minor = tonumber(tnt_version[2])
if tnt_major < 2 or (tnt_major == 2 and tnt_minor < 2) then
  local notify_socket = os.getenv('NOTIFY_SOCKET')
  if notify_socket then
      local socket = require('socket')
      local sock = assert(socket('AF_UNIX', 'SOCK_DGRAM', 0), 'Can not create socket')
      sock:sendto('unix/', notify_socket, 'READY=1')
  end
end
'''

    with open(os.path.join(project.path, 'init.lua'), 'w') as f:
        f.write(patched_init)

    with open(os.path.join(project.path, 'stateboard.init.lua'), 'w') as f:
        f.write(patched_init)

    return project
Ejemplo n.º 2
0
def project_ignore_sigterm(cartridge_cmd, short_tmpdir):
    project = Project(cartridge_cmd, 'ignore-sigterm', short_tmpdir,
                      'cartridge')

    remove_all_dependencies(project)

    replace_project_file(project, 'init.lua', INIT_IGNORE_SIGTERM_FILEPATH)
    replace_project_file(project, 'stateboard.init.lua',
                         INIT_IGNORE_SIGTERM_FILEPATH)

    return project
Ejemplo n.º 3
0
def project_without_dependencies(cartridge_cmd, short_tmpdir):
    project = Project(cartridge_cmd, 'empty-project', short_tmpdir,
                      'cartridge')

    remove_all_dependencies(project)

    replace_project_file(project, 'init.lua', INIT_NO_CARTRIDGE_FILEPATH)
    replace_project_file(project, 'stateboard.init.lua',
                         INIT_NO_CARTRIDGE_FILEPATH)

    return project
Ejemplo n.º 4
0
def project_ignore_sigterm(cartridge_cmd, short_tmpdir):
    project = Project(cartridge_cmd, 'ignore-sigterm', short_tmpdir,
                      'cartridge')

    remove_all_dependencies(project)
    # This is necessary, because default app config has parameter `stateboard: true`
    remove_project_file(project, '.cartridge.yml')

    replace_project_file(project, 'init.lua', INIT_IGNORE_SIGTERM_FILEPATH)
    replace_project_file(project, 'stateboard.init.lua',
                         INIT_IGNORE_SIGTERM_FILEPATH)

    return project
Ejemplo n.º 5
0
def project_custom_rundir(cartridge_cmd, short_tmpdir):
    project = Project(cartridge_cmd, 'empty-project', short_tmpdir,
                      'cartridge')

    remove_all_dependencies(project)

    replace_project_file(project, '.cartridge.yml', RUNDIR_CLI_CONF)

    replace_project_file(project, 'init.lua', INIT_NO_CARTRIDGE_FILEPATH)
    replace_project_file(project, 'stateboard.init.lua',
                         INIT_NO_CARTRIDGE_FILEPATH)

    return project
Ejemplo n.º 6
0
def project_without_dependencies(cartridge_cmd, short_tmpdir):
    project = Project(cartridge_cmd, 'empty-project', short_tmpdir,
                      'cartridge')

    remove_all_dependencies(project)

    # This is necessary, because default app config has parameter `stateboard: true`
    remove_project_file(project, '.cartridge.yml')

    replace_project_file(project, 'init.lua', INIT_NO_CARTRIDGE_FILEPATH)
    replace_project_file(project, 'stateboard.init.lua',
                         INIT_NO_CARTRIDGE_FILEPATH)

    return project
Ejemplo n.º 7
0
def project_with_capital_letters_name(cartridge_cmd, short_tmpdir):
    project = Project(cartridge_cmd, 'App-withoutDependencies01', short_tmpdir,
                      'cartridge')

    remove_all_dependencies(project)

    # Remove file with Cartridge configuration, because default app
    # config has parameter `stateboard: true`
    remove_project_file(project, '.cartridge.yml')

    replace_project_file(project, 'init.lua', INIT_NO_CARTRIDGE_FILEPATH)
    replace_project_file(project, 'stateboard.init.lua',
                         INIT_NO_CARTRIDGE_FILEPATH)

    return project
Ejemplo n.º 8
0
def project_ignore_sigterm(cartridge_cmd, short_tmpdir):
    project = Project(cartridge_cmd, 'ignore-sigterm', short_tmpdir, 'cartridge')

    remove_all_dependencies(project)

    patched_init = '''#!/usr/bin/env tarantool
local fiber = require('fiber')
fiber.create(function()
    fiber.sleep(1)
end)

require('log').info('I am starting...')

-- ignore SIGTERM
local ffi = require('ffi')
local SIG_IGN = 1
local SIGTERM = 15
ffi.cdef[[
    void (*signal(int sig, void (*func)(int)))(int);
]]
local ignore_handler = ffi.cast("void (*)(int)", SIG_IGN)
ffi.C.signal(SIGTERM, ignore_handler)

-- Copied from cartridge.cfg to provide support for NOTIFY_SOCKET in old tarantool
local tnt_version = string.split(_TARANTOOL, '.')
local tnt_major = tonumber(tnt_version[1])
local tnt_minor = tonumber(tnt_version[2])
if tnt_major < 2 or (tnt_major == 2 and tnt_minor < 2) then
  local notify_socket = os.getenv('NOTIFY_SOCKET')
  if notify_socket then
      local socket = require('socket')
      local sock = assert(socket('AF_UNIX', 'SOCK_DGRAM', 0), 'Can not create socket')
      sock:sendto('unix/', notify_socket, 'READY=1')
  end
end
'''

    with open(os.path.join(project.path, 'init.lua'), 'w') as f:
        f.write(patched_init)

    with open(os.path.join(project.path, 'stateboard.init.lua'), 'w') as f:
        f.write(patched_init)

    return project
Ejemplo n.º 9
0
def project_without_dependencies(cartridge_cmd, tmpdir):
    project = Project(cartridge_cmd, 'empty-project', tmpdir, 'cartridge')

    remove_all_dependencies(project)
    return project