Mercurial Hosting > luan
comparison host/admin/src/private/tools/clean_logs.luan @ 1995:301a6561fb6b
add host/admin
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Fri, 04 Jul 2025 10:25:38 -0600 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1994:035996323891 | 1995:301a6561fb6b |
|---|---|
| 1 local Luan = require "luan:Luan.luan" | |
| 2 local error = Luan.error | |
| 3 local ipairs = Luan.ipairs or error() | |
| 4 local String = require "luan:String.luan" | |
| 5 local regex = String.regex or error() | |
| 6 local Io = require "luan:Io.luan" | |
| 7 local Http = require "luan:http/Http.luan" | |
| 8 local Utils = require "site:/private/lib/Utils.luan" | |
| 9 | |
| 10 | |
| 11 local web_log_regex = regex[[^web.*\.log$]] | |
| 12 | |
| 13 return function() | |
| 14 Http.response.headers["content-type"] = "text/plain" | |
| 15 Io.stdout = Http.response.text_writer() | |
| 16 local dirs = Utils.sites_dir.children() | |
| 17 for _, site_dir in ipairs(dirs) do | |
| 18 local log_dir = site_dir.child("site/private/local/logs") | |
| 19 if log_dir.exists() then | |
| 20 log_dir.child("luan.log").delete() | |
| 21 for _, f in ipairs(log_dir.children()) do | |
| 22 if web_log_regex.matches(f.name()) then | |
| 23 f.delete() | |
| 24 end_if | |
| 25 end_for | |
| 26 end_if | |
| 27 end_for | |
| 28 %> | |
| 29 done | |
| 30 <% | |
| 31 end_function |
