I have a Lua script which is split into multiple files, like: /etc/kamailio/routing/ ├── main.lua ├── logger.lua └── db.lua
On restart, Kamailio fails to start with an error: main.lua:2: module 'logger' not found:\n\tno field package.preload
If I set multiple files in the modparam parameter: modparam("app_lua", "load", "/etc/kamailio/routing/main.lua") modparam("app_lua", "load", "/etc/kamailio/routing/logger.lua")
I'm getting the same error. Is it possible to load multiple files, or is this a limit to a single file currently?
You can use this module https://github.com/hajekmi/call.lua
On Tue 1. 10. 2024 at 14:30, Ilie Soltanici via sr-users < sr-users@lists.kamailio.org> wrote:
I have a Lua script which is split into multiple files, like: /etc/kamailio/routing/ ├── main.lua ├── logger.lua └── db.lua
On restart, Kamailio fails to start with an error: main.lua:2: module 'logger' not found:\n\tno field package.preload
If I set multiple files in the modparam parameter: modparam("app_lua", "load", "/etc/kamailio/routing/main.lua") modparam("app_lua", "load", "/etc/kamailio/routing/logger.lua")
I'm getting the same error. Is it possible to load multiple files, or is this a limit to a single file currently? __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender! Edit mailing list options or unsubscribe:
You can configure the lookup path for the lua library in kamailio.lua
------ local cur_dir = debug.getinfo(1).source cur_dir = string.gsub(debug.getinfo(1).source, "^@(.+/)kamailio.lua$", "%1") package.path = package.path .. ";" .. cur_dir .. "?.lua" package.path = package.path .. ";" .. cur_dir .. "routing/?.lua" local utils = require 'logger' ---------
I would just use do_file to load more lua files
see https://git.xswitch.cn/book/kamailio-book-examples/src/branch/master/etc/exa...
On Thu, Oct 3, 2024 at 12:58 AM qwerse--- via sr-users < sr-users@lists.kamailio.org> wrote:
You can configure the lookup path for the lua library in kamailio.lua
local cur_dir = debug.getinfo(1).source cur_dir = string.gsub(debug.getinfo(1).source, "^@(.+/)kamailio.lua$", "%1") package.path = package.path .. ";" .. cur_dir .. "?.lua" package.path = package.path .. ";" .. cur_dir .. "routing/?.lua" local utils = require 'logger'
Kamailio - Users Mailing List - Non Commercial Discussions To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender! Edit mailing list options or unsubscribe: