Mercurial Hosting > luan
comparison src/luan/modules/http/tools/java_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/java_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 | |
9 | |
10 return function() | |
11 Io.stdout = Http.response.text_writer() | |
12 | |
13 local threads = Thread.getAllStackTraces() | |
14 local threads = {} | |
15 for thread, trace in Luan.pairs(Thread.getAllStackTraces()) do | |
16 threads[#threads+1] = { | |
17 trace = trace | |
18 string = thread.toString() | |
19 state = thread.getState() | |
20 } | |
21 end | |
22 %> | |
23 <!doctype html> | |
24 <html> | |
25 <body> | |
26 <h1>Java Threads</h1> | |
27 <p><%=Http.request.headers["host"]%> - <%=Time.format(Time.now())%></p> | |
28 <% | |
29 local count = 0 | |
30 for _, thread in Luan.ipairs(threads) do | |
31 %> | |
32 <p><%=thread.string%> <%=thread.state%> | |
33 <ul> | |
34 <% | |
35 local trace = thread.trace | |
36 for i in Luan.range( 0 , trace.length - 1 ) do | |
37 local line = trace[i].toString() | |
38 %><li><%=line%></li><% | |
39 end | |
40 %> | |
41 </ul></p> | |
42 <% | |
43 count = count + 1 | |
44 end | |
45 %> | |
46 <p><%=count%> threads found</p> | |
47 | |
48 </body> | |
49 </html> | |
50 <% | |
51 end |