Mercurial Hosting > luan
comparison src/luan/modules/http/tools/Java_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/java_threads.html.luan@a50803fde972 |
children | 8d95711f6615 |
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 | |
9 | |
10 local Java_threads = {} | |
11 | |
12 function Java_threads.respond() | |
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>Java 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 %> | |
34 <p><%=thread.string%> <%=thread.state%> | |
35 <ul> | |
36 <% | |
37 local trace = thread.trace | |
38 for i in Luan.range( 0 , trace.length - 1 ) do | |
39 local line = trace[i].toString() | |
40 %><li><%=line%></li><% | |
41 end | |
42 %> | |
43 </ul></p> | |
44 <% | |
45 count = count + 1 | |
46 end | |
47 %> | |
48 <p><%=count%> threads found</p> | |
49 | |
50 </body> | |
51 </html> | |
52 <% | |
53 end | |
54 | |
55 return Java_threads |