Mercurial Hosting > luan
comparison src/luan/host/WebHandler.java @ 1400:221eedb0f54e
fix inner class gc bug
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 13 Sep 2019 05:05:51 -0600 |
parents | 002152af497a |
children | 27efb1fcbcb5 |
comparison
equal
deleted
inserted
replaced
1399:38a1c1b4279a | 1400:221eedb0f54e |
---|---|
22 private static final Logger logger = LoggerFactory.getLogger(WebHandler.class); | 22 private static final Logger logger = LoggerFactory.getLogger(WebHandler.class); |
23 | 23 |
24 private static final DomainHandler.Factory factory = new DomainHandler.Factory() { | 24 private static final DomainHandler.Factory factory = new DomainHandler.Factory() { |
25 public Handler newHandler(String domain) { | 25 public Handler newHandler(String domain) { |
26 File dir = new File(sitesDir,domain); | 26 File dir = new File(sitesDir,domain); |
27 if( !dir.exists() /* && !recover(dir) */ ) | 27 if( !dir.exists() ) |
28 return null; | 28 return null; |
29 String dirStr = dir.toString(); | 29 String dirStr = dir.toString(); |
30 | 30 |
31 String logDir = dirStr + "/site/private/local/logs/web"; | 31 String logDir = dirStr + "/site/private/local/logs/web"; |
32 new File(logDir).mkdirs(); | 32 new File(logDir).mkdirs(); |
33 | 33 |
34 Luan luan = new Luan(); | 34 Luan luan = new Luan(); |
35 Log4j.newLoggerRepository(luan); | 35 Log4j.newLoggerRepository(luan); |
36 initLuan(luan,dirStr,domain); | 36 initLuan(luan,dirStr,domain); |
37 return new LuanHandler(luan); | 37 return new LuanHandler(luan,domain); |
38 } | 38 } |
39 }; | 39 }; |
40 | 40 |
41 public static String securityPassword = "password"; // change for security | 41 public static String securityPassword = "password"; // change for security |
42 private static final DomainHandler domainHandler = new DomainHandler(factory); | 42 private static final DomainHandler domainHandler = new DomainHandler(factory); |
57 public static Object callSite(String domain,String fnName,Object... args) throws LuanException { | 57 public static Object callSite(String domain,String fnName,Object... args) throws LuanException { |
58 LuanHandler luanHandler = (LuanHandler)domainHandler.getHandler(domain); | 58 LuanHandler luanHandler = (LuanHandler)domainHandler.getHandler(domain); |
59 return luanHandler.call_rpc(fnName,args); | 59 return luanHandler.call_rpc(fnName,args); |
60 } | 60 } |
61 | 61 |
62 /* | |
63 private static boolean recover(File dir) { | |
64 File backups = new File(dir.getParentFile().getParentFile(),"backups"); | |
65 if( !backups.exists() ) | |
66 return false; | |
67 String name = dir.getName(); | |
68 File from = null; | |
69 for( File backup : backups.listFiles() ) { | |
70 File d = new File(backup,"current/"+name); | |
71 if( d.exists() && (from==null || from.lastModified() < d.lastModified()) ) | |
72 from = d; | |
73 } | |
74 if( from == null ) | |
75 return false; | |
76 if( !from.renameTo(dir) ) | |
77 throw new RuntimeException("couldn't rename "+from+" to "+dir); | |
78 logger.info("recovered "+name+" from "+from); | |
79 return true; | |
80 } | |
81 */ | |
82 private static void initLuan(Luan luan,String dir,String domain) { | 62 private static void initLuan(Luan luan,String dir,String domain) { |
83 security(luan,dir); | 63 security(luan,dir); |
84 try { | 64 try { |
85 LuanFunction fn = BasicLuan.load_file(luan,"classpath:luan/host/init.luan"); | 65 LuanFunction fn = BasicLuan.load_file(luan,"classpath:luan/host/init.luan"); |
86 fn.call(dir,domain); | 66 fn.call(dir,domain); |