Mercurial Hosting > luan
view src/luan/host/Init.luan @ 1154:bbad9a21277c
remove Http.run_later
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 04 Feb 2018 20:34:56 -0700 |
parents | 707a5d874f3e |
children | 3a0f58d09ee7 |
line wrap: on
line source
local Luan = require "luan:Luan.luan" local error = Luan.error local String = require "luan:String.luan" local gsub = String.gsub or error() local Io = require "luan:Io.luan" local Http = require "luan:http/Http.luan" local Hosting = require "luan:host/Hosting.luan" local Mail = require "luan:mail/Mail.luan" local Init = {} local dir, domain = ... Init.password = Io.schemes.file(dir).child("password").read_text() Http.dir = "file:"..dir.."/site" function Io.schemes.site(path,loading) return Io.uri( Http.dir..path, loading ) end Hosting.domain = domain Io.password = Init.password -- logging java() local Logger = require "java:org.apache.log4j.Logger" local Logging = require "luan:logging/Logging.luan" local root = gsub(domain,"\.",":") Logging.layout = "%d %-5p %c{-1} - %m%n" Logging.file = dir.."/site/private/local/logs/luan.log" Logging.max_file_size = "1MB" local one_mb = 1048576 local log_dir = dir.."/site/private/local/logs/" Logging.appenders = { [log_dir.."error.log"] = "ERROR" [log_dir.."warn.log"] = "WARN" [log_dir.."info.log"] = "INFO" } Logging.log4j_root_logger = Logger.getLogger(root) Logging.log4j_root_logger.setAdditivity(false) local old_log_to_file = Logging.log_to_file function Logging.log_to_file(file,logger_name) Io.schemes.file(file) -- security check logger_name = logger_name and root .. "." .. logger_name local appender = old_log_to_file(file,logger_name) appender.getMaximumFileSize() <= one_mb or error "Logging.max_file_size is too big" return appender end local old_init = Logging.init function Logging.init() Logging.appenders["System.err"] = nil Logging.appenders["System.out"] = nil old_init() end Logging.init() local old_logger = Logging.logger function Logging.root_logger() return old_logger(root) end function Logging.logger(name) return old_logger( root .. "." .. name ) end Init.logger_root = root.."." -- mail - fix later Hosting.send_mail = Mail.Sender{ host = "smtpcorp.com"; username = "smtp@luanhost.com"; -- ? password = "luanhost"; port = 2525; }.send return Init