diff mod_traceback/mod_traceback.lua @ 2773:7a4e8dbbd30d

mod_traceback: Write current stack trace to file on SIGUSR1
author Matthew Wild <mwild1@gmail.com>
date Mon, 25 Sep 2017 11:20:05 +0100
parents
children dde9d21a599f
line wrap: on
line diff
--- /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);
+