comparison mod_auth_external/mod_auth_external.lua @ 197:2686221255cf

restart authorize command if crashed or ended; added example shell script
author Bjoern Kalkbrenner <terminar@cyberphoria.org>
date Wed, 07 Jul 2010 13:27:46 +0200
parents cd8492748985
children 3da3d6480e65
comparison
equal deleted inserted replaced
196:a1c2677257da 197:2686221255cf
28 28
29 --local proc; 29 --local proc;
30 local pid; 30 local pid;
31 local readfile; 31 local readfile;
32 local writefile; 32 local writefile;
33
33 local function send_query(text) 34 local function send_query(text)
34 -- if not proc then 35 if pid and lpc.wait(pid,1) ~= nil then
36 log("debug","error, process died, force reopen");
37 pid=nil;
38 end
35 if not pid then 39 if not pid then
36 log("debug", "Opening process"); 40 log("debug", "Opening process " .. command);
37 -- proc = process.popen(command); 41 -- proc = process.popen(command);
38 pid, writefile, readfile = lpc.run(command); 42 pid, writefile, readfile = lpc.run(command);
39 end 43 end
40 -- if not proc then 44 -- if not proc then
41 if not pid then 45 if not pid then
42 log("debug", "Process failed to open"); 46 log("debug", "Process failed to open");
43 return nil; 47 return nil;
44 end 48 end
45 -- proc:write(text); 49 -- proc:write(text);
46 -- proc:flush(); 50 -- proc:flush();
51
47 writefile:write(text); 52 writefile:write(text);
48 writefile:flush(); 53 writefile:flush();
49 if script_type == "ejabberd" then 54 if script_type == "ejabberd" then
50 -- return proc:read(4); -- FIXME do properly 55 -- return proc:read(4); -- FIXME do properly
51 return readfile:read(4); -- FIXME do properly 56 return readfile:read(4); -- FIXME do properly