mod_traceback: Write current stack trace to file on SIGUSR1
authorMatthew Wild <mwild1@gmail.com>
Mon, 25 Sep 2017 11:20:05 +0100
changeset 2777 7a4e8dbbd30d
parent 2776 2c59f2f0c37d
child 2778 41565a743cad
mod_traceback: Write current stack trace to file on SIGUSR1
mod_traceback/mod_traceback.lua
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_traceback/mod_traceback.lua	Mon Sep 25 11:20:05 2017 +0100
@@ -0,0 +1,11 @@
+module:set_global();
+
+local traceback = require "util.debug".traceback;
+
+require"util.signal".signal(module:get_option_string(module.name, "SIGUSR1"), function ()
+	module:log("info", "Received SIGUSR1, writing traceback");
+	local f = io.open(prosody.paths.data.."/traceback.txt", "a+");
+	f:write(traceback(), "\n");
+	f:close();
+end);
+