Mercurial Hosting > luan
comparison src/luan/modules/http/tools/java_threads.luan @ 790:4cddfc06a34f
add java_threads and luan_threads
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 04 Sep 2016 20:47:19 -0600 |
parents | |
children | 0842b9b570f8 |
comparison
equal
deleted
inserted
replaced
789:e2eb55d86bb2 | 790:4cddfc06a34f |
---|---|
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 <html> | |
24 <body> | |
25 <h1>Java Threads</h1> | |
26 <p><%=Http.request.header.host%> - <%=Time.format(Time.now())%></p> | |
27 <% | |
28 local count = 0 | |
29 for _, thread in Luan.ipairs(threads) do | |
30 %> | |
31 <p><%=thread.string%> <%=thread.state%> | |
32 <ul> | |
33 <% | |
34 local trace = thread.trace | |
35 for i in Luan.range( 0 , trace.length - 1 ) do | |
36 local line = trace[i].toString() | |
37 %><li><%=line%></li><% | |
38 end | |
39 %> | |
40 </ul></p> | |
41 <% | |
42 count = count + 1 | |
43 end | |
44 %> | |
45 <p><%=count%> threads found</p> | |
46 | |
47 </body> | |
48 </html> | |
49 <% | |
50 end |