comparison mod_traceback/mod_traceback.lua @ 5851:dde9d21a599f

mod_traceback: Hook signal via event instead of directly Safer this way, see Prosody trunk rev 69faf3552d52
author Kim Alvefur <zash@zash.se>
date Sat, 02 Mar 2024 14:47:09 +0100
parents 7a4e8dbbd30d
children
comparison
equal deleted inserted replaced
5850:0358fcf14cd6 5851:dde9d21a599f
1 module:set_global(); 1 module:set_global();
2 2
3 local traceback = require "util.debug".traceback; 3 local traceback = require "util.debug".traceback;
4 4
5 require"util.signal".signal(module:get_option_string(module.name, "SIGUSR1"), function () 5 local signal = module:get_option_string(module.name, "SIGUSR1");
6 module:log("info", "Received SIGUSR1, writing traceback"); 6 module:hook("signal/" .. signal, function()
7 local f = io.open(prosody.paths.data.."/traceback.txt", "a+"); 7 module:log("info", "Received %s, writing traceback", signal);
8 local f = io.open(prosody.paths.data .. "/traceback.txt", "a+");
8 f:write(traceback(), "\n"); 9 f:write(traceback(), "\n");
9 f:close(); 10 f:close();
10 end); 11 end);
11 12