Mercurial Hosting > luan
annotate src/luan/host/run.luan @ 1181:51d1342e25ad
luanhost password handling
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 20 Feb 2018 19:50:30 -0700 |
parents | 707a5d874f3e |
children |
rev | line source |
---|---|
1181
51d1342e25ad
luanhost password handling
Franklin Schmidt <fschmidt@gmail.com>
parents:
1135
diff
changeset
|
1 require "luan:logging/init.luan" -- initialize logging |
1135 | 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" | |
1181
51d1342e25ad
luanhost password handling
Franklin Schmidt <fschmidt@gmail.com>
parents:
1135
diff
changeset
|
10 local Logging = require "luan:logging/Logging.luan" |
51d1342e25ad
luanhost password handling
Franklin Schmidt <fschmidt@gmail.com>
parents:
1135
diff
changeset
|
11 local logger = Logging.logger "run" |
1135 | 12 |
13 | |
14 local here = Io.schemes.file(".").canonical().to_string() | |
15 Hosting.sites_dir = here.."/sites/" | |
1181
51d1342e25ad
luanhost password handling
Franklin Schmidt <fschmidt@gmail.com>
parents:
1135
diff
changeset
|
16 |
51d1342e25ad
luanhost password handling
Franklin Schmidt <fschmidt@gmail.com>
parents:
1135
diff
changeset
|
17 -- tmp |
51d1342e25ad
luanhost password handling
Franklin Schmidt <fschmidt@gmail.com>
parents:
1135
diff
changeset
|
18 local Util = require "classpath:luan/host/Util.luan" |
51d1342e25ad
luanhost password handling
Franklin Schmidt <fschmidt@gmail.com>
parents:
1135
diff
changeset
|
19 local sites_dir = Io.schemes.file(Hosting.sites_dir) |
51d1342e25ad
luanhost password handling
Franklin Schmidt <fschmidt@gmail.com>
parents:
1135
diff
changeset
|
20 for _, site in ipairs(sites_dir.children()) do |
51d1342e25ad
luanhost password handling
Franklin Schmidt <fschmidt@gmail.com>
parents:
1135
diff
changeset
|
21 local password_file = site.child("password") |
51d1342e25ad
luanhost password handling
Franklin Schmidt <fschmidt@gmail.com>
parents:
1135
diff
changeset
|
22 if password_file.exists() then |
51d1342e25ad
luanhost password handling
Franklin Schmidt <fschmidt@gmail.com>
parents:
1135
diff
changeset
|
23 local domain = site.name() |
51d1342e25ad
luanhost password handling
Franklin Schmidt <fschmidt@gmail.com>
parents:
1135
diff
changeset
|
24 local password = password_file.read_text() |
51d1342e25ad
luanhost password handling
Franklin Schmidt <fschmidt@gmail.com>
parents:
1135
diff
changeset
|
25 Util.write_password(domain,password) |
51d1342e25ad
luanhost password handling
Franklin Schmidt <fschmidt@gmail.com>
parents:
1135
diff
changeset
|
26 password_file.delete() |
51d1342e25ad
luanhost password handling
Franklin Schmidt <fschmidt@gmail.com>
parents:
1135
diff
changeset
|
27 logger.info("fixed password for "..domain) |
51d1342e25ad
luanhost password handling
Franklin Schmidt <fschmidt@gmail.com>
parents:
1135
diff
changeset
|
28 end |
51d1342e25ad
luanhost password handling
Franklin Schmidt <fschmidt@gmail.com>
parents:
1135
diff
changeset
|
29 end |
51d1342e25ad
luanhost password handling
Franklin Schmidt <fschmidt@gmail.com>
parents:
1135
diff
changeset
|
30 |
1135 | 31 do_file "classpath:luan/host/main.luan" |
32 | |
33 | |
34 -- web server | |
35 | |
36 java() | |
37 local Server = require "java:org.eclipse.jetty.server.Server" | |
38 local DefaultHandler = require "java:org.eclipse.jetty.server.handler.DefaultHandler" | |
39 local HandlerCollection = require "java:org.eclipse.jetty.server.handler.HandlerCollection" | |
40 local SessionHandler = require "java:org.eclipse.jetty.server.session.SessionHandler" | |
41 local SslSelectChannelConnector = require "java:org.eclipse.jetty.server.ssl.SslSelectChannelConnector" | |
42 local WebHandler = require "java:luan.host.WebHandler" | |
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 ]] |