If the file loaded with the modparam "load" uses CommonJS modules (Issue #3037-PR #3038), the modules are not reloaded when issuing the command app_jsdt.reload. Only the "main" file is reloaded.
1 - Start Kamailio with those files as the initial configuration
# kamailio.cfg
## Only the part concerning app_jsdt is included.
## The rest of the config file is ommited for the sake of clarity
loadmodule "app_jsdt.so"
modparam("app_jsdt", "load", "/etc/kamailio/js/index.js")
modparam("app_jsdt", "mode", 1)
cfgengine "jsdt"
// index.js
var myModule = require('./myModule');
function ksr_request_route() {
myModule.myFunction()
KSR.log("info", "KSR.log called from the index.js file");
}
// myModule.js
exports.myFunction = function() {
KSR.log("info", "KSR.log called from the myModule.js file"
}
2 - Modify the myModule.js file
// myModule.js
exports.myFunction = function() {
KSR.log("info", "KSR.log called from the MODIFIED myModule.js file"
}
3 - Run the reload command
foo@bar:~# kamcmd app_jsdt.reload
{
old: 0
new: 1
}
Log file
INFO: app_jsdt [app_jsdt_api.c:1557]: app_jsdt_rpc_reload(): marking for reload js script file: /etc/kamailio/js/index.js (0 => 0)
DEBUG: app_jsdt [app_jsdt_api.c:534]: jsdt_kemi_reload_script(): reloading js script file: /etc/kamailio/js/index.js (0 => 1)
4 - The log file still show those lines:
Log file
INFO [core/kemi.c:156]: sr_kemi_core_log(): KSR.log called from the myModule.js file
INFO [core/kemi.c:156]: sr_kemi_core_log(): KSR.log called from the index.js file
5 - Modify the index.js file
// index.js
var myModule = require('./myModule');
function ksr_request_route() {
myModule.myFunction()
KSR.log("info", "KSR.log called from the MODIFIED index.js file");
}
6 - Run the reload command
foo@bar:~# kamcmd app_jsdt.reload
{
old: 1
new: 2
}
Log file
INFO: app_jsdt [app_jsdt_api.c:1557]: app_jsdt_rpc_reload(): marking for reload js script file: /etc/kamailio/js/index.js (0 => 1)
DEBUG: app_jsdt [app_jsdt_api.c:534]: jsdt_kemi_reload_script(): reloading js script file: /etc/kamailio/js/index.js (1 => 2)
7 - The log file now show those lines:
Log file
INFO [core/kemi.c:156]: sr_kemi_core_log(): KSR.log called from the myModule.js file
INFO [core/kemi.c:156]: sr_kemi_core_log(): KSR.log called from the MODIFIED index.js file
8 - Restart kamailio completly
9 - The log file now show those lines:
Log file
INFO [core/kemi.c:156]: sr_kemi_core_log(): KSR.log called from the MODIFIED myModule.js file
INFO [core/kemi.c:156]: sr_kemi_core_log(): KSR.log called from the MODIFIED index.js file
Sorry, I would really like to provide one, but, as I'm a new Kamailio user, I don't know all the internals yet.
foo@bar:~# kamailio -v
version: kamailio 5.6.0 (x86_64/linux)
flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLOCKLIST, HAVE_RESOLV_RES, TLS_PTHREAD_MUTEX_SHARED
ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: unknown
compiled with gcc 10.2.1
foo@bar:~# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 11 (bullseye)
Release: 11
Codename: bullseye
foo@bar:~# uname -a
Linux localhost 5.10.0-14-amd64 #1 SMP Debian 5.10.113-1 (2022-04-29) x86_64 GNU/Linux
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.