Mercurial Hosting > luan
diff src/luan/host/run.luan @ 1188:9f5edbef3f55
remove old web log files
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 22 Feb 2018 23:21:06 -0700 |
parents | 83c8a5a47f70 |
children | 1e351b0d385e |
line wrap: on
line diff
--- a/src/luan/host/run.luan Thu Feb 22 18:38:45 2018 -0700 +++ b/src/luan/host/run.luan Thu Feb 22 23:21:06 2018 -0700 @@ -6,6 +6,8 @@ local Io = require "luan:Io.luan" local print = Io.print or error() local String = require "luan:String.luan" +local Time = require "luan:Time.luan" +local Thread = require "luan:Thread.luan" local Hosting = require "luan:host/Hosting.luan" local Logging = require "luan:logging/Logging.luan" local logger = Logging.logger "run" @@ -31,3 +33,20 @@ handler = SafeHandler.new(handler) local server = Server.ForAddress.new("127.0.0.1",8080,handler) server.start() + + + +local function remove_old_web_log_files() + local expired = Time.now() - Time.period{days=30} + local sites_dir = Io.schemes.file(Hosting.sites_dir) + for _, site in ipairs(sites_dir.children()) do + local web = site.child("site/private/local/logs/web") + for _, file in ipairs(web.children() or {}) do + if file.last_modified() < expired then + file.delete() + end + end + end +end + +Thread.schedule( Time.period{days=1}, true, Thread.safe(remove_old_web_log_files,logger) )