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