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