Mercurial Hosting > luan
comparison src/luan/host/jetty/run.luan @ 1182:0b55a1af5a44
add luan/host/jetty
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 20 Feb 2018 21:08:04 -0700 |
parents | src/luan/host/run.luan@51d1342e25ad |
children |
comparison
equal
deleted
inserted
replaced
1181:51d1342e25ad | 1182:0b55a1af5a44 |
---|---|
1 require "luan:logging/init.luan" -- initialize logging | |
2 local Luan = require "luan:Luan.luan" | |
3 local error = Luan.error | |
4 local do_file = Luan.do_file or error() | |
5 local ipairs = Luan.ipairs or error() | |
6 local Io = require "luan:Io.luan" | |
7 local print = Io.print or error() | |
8 local String = require "luan:String.luan" | |
9 local Hosting = require "luan:host/Hosting.luan" | |
10 local Logging = require "luan:logging/Logging.luan" | |
11 local logger = Logging.logger "run" | |
12 java() | |
13 local WebHandler = require "java:luan.host.jetty.WebHandler" | |
14 Hosting.WebHandler = WebHandler | |
15 | |
16 local here = Io.schemes.file(".").canonical().to_string() | |
17 Hosting.sites_dir = here.."/sites/" | |
18 | |
19 -- tmp | |
20 local Util = require "classpath:luan/host/Util.luan" | |
21 local sites_dir = Io.schemes.file(Hosting.sites_dir) | |
22 for _, site in ipairs(sites_dir.children()) do | |
23 local password_file = site.child("password") | |
24 if password_file.exists() then | |
25 local domain = site.name() | |
26 local password = password_file.read_text() | |
27 Util.write_password(domain,password) | |
28 password_file.delete() | |
29 logger.info("fixed password for "..domain) | |
30 end | |
31 end | |
32 | |
33 do_file "classpath:luan/host/main.luan" | |
34 | |
35 | |
36 -- web server | |
37 | |
38 local Server = require "java:org.eclipse.jetty.server.Server" | |
39 local DefaultHandler = require "java:org.eclipse.jetty.server.handler.DefaultHandler" | |
40 local HandlerCollection = require "java:org.eclipse.jetty.server.handler.HandlerCollection" | |
41 local SessionHandler = require "java:org.eclipse.jetty.server.session.SessionHandler" | |
42 local SslSelectChannelConnector = require "java:org.eclipse.jetty.server.ssl.SslSelectChannelConnector" | |
43 | |
44 local server = Server.new(8080) | |
45 | |
46 local handlers = HandlerCollection.new() | |
47 handlers.setHandlers { | |
48 SessionHandler.new(), | |
49 WebHandler.new(Hosting.sites_dir,server), | |
50 DefaultHandler.new() | |
51 } | |
52 server.setHandler(handlers); | |
53 | |
54 server.start() | |
55 | |
56 | |
57 --[[ | |
58 local tp = server.getThreadPool() | |
59 print(tp) | |
60 print(tp.getClass()) | |
61 print("max "..tp.getMaxThreads()) | |
62 print("getMaxQueued "..tp.getMaxQueued()) | |
63 | |
64 for _, c in ipairs(server.getConnectors()) do | |
65 print(c) | |
66 tp = c.getThreadPool() | |
67 print(tp) | |
68 end | |
69 | |
70 print "done" | |
71 ]] |