Mercurial Hosting > luan
comparison src/luan/modules/http/tools/Luan_threads.luan @ 1246:299996e03876
clean up http/tools
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 17 Jul 2018 15:43:11 -0600 |
parents | src/luan/modules/http/tools/luan_threads.html.luan@a50803fde972 |
children | 4b5b84853f6f |
comparison
equal
deleted
inserted
replaced
1245:2de84f128be3 | 1246:299996e03876 |
---|---|
1 local Luan = require "luan:Luan.luan" | |
2 local error = Luan.error | |
3 local Io = require "luan:Io.luan" | |
4 local Time = require "luan:Time.luan" | |
5 local Http = require "luan:http/Http.luan" | |
6 java() | |
7 local Thread = require "java:java.lang.Thread" | |
8 local LuanException = require "java:luan.LuanException" | |
9 local JavaLuan = require "java:luan.Luan" | |
10 | |
11 | |
12 local Luan_threads = {} | |
13 | |
14 function Luan_threads.respond() | |
15 Io.stdout = Http.response.text_writer() | |
16 | |
17 local threads = Thread.getAllStackTraces() | |
18 local threads = {} | |
19 for thread, trace in Luan.pairs(Thread.getAllStackTraces()) do | |
20 threads[#threads+1] = { | |
21 trace = trace | |
22 string = thread.toString() | |
23 state = thread.getState() | |
24 } | |
25 end | |
26 %> | |
27 <!doctype html> | |
28 <html> | |
29 <body> | |
30 <h1>Luan Threads</h1> | |
31 <p><%=Http.request.headers["host"]%> - <%=Time.format(Time.now())%></p> | |
32 <% | |
33 local count = 0 | |
34 for _, thread in Luan.ipairs(threads) do | |
35 local luan_trace = JavaLuan.table(LuanException.justLuan(thread.trace)) | |
36 if #luan_trace > 0 then | |
37 %> | |
38 <p><%=thread.string%> <%=thread.state%> | |
39 <ul> | |
40 <% | |
41 for i, el in Luan.ipairs(luan_trace) do | |
42 local line = LuanException.toString(el); | |
43 %><li><%=line%></li><% | |
44 end | |
45 %> | |
46 </ul></p> | |
47 <% | |
48 count = count + 1 | |
49 end | |
50 end | |
51 %> | |
52 <p><%=count%> threads found</p> | |
53 | |
54 </body> | |
55 </html> | |
56 <% | |
57 end | |
58 | |
59 return Luan_threads |