Mercurial Hosting > luan
changeset 1615:38894708bade
better init.luan exception handling
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 03 Jun 2021 18:00:49 -0600 |
parents | 557bb90b70d7 |
children | 915cb538e2a3 |
files | src/luan/modules/http/LuanHandler.java |
diffstat | 1 files changed, 12 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/luan/modules/http/LuanHandler.java Tue May 25 13:21:31 2021 -0600 +++ b/src/luan/modules/http/LuanHandler.java Thu Jun 03 18:00:49 2021 -0600 @@ -43,7 +43,7 @@ private final ReadWriteLock rwLock = new ReentrantReadWriteLock(); private volatile Luan currentLuan; private volatile boolean isDisabled = false; - private volatile LuanException initErr; + private volatile boolean didInit; private static final Method resetLuanMethod; private static final Method evalInRootMethod; @@ -84,18 +84,24 @@ logger.info("gc "+domain); } + private void init(Luan luan) throws LuanException { + if( didInit ) + return; + PackageLuan.load(luan,"site:/init.luan",null); + didInit = true; + } + private void newLuan() { Luan luan; synchronized(luanInit) { luan = new Luan(luanInit); } - initErr = null; + didInit = false; LuanLogger.startThreadLogging(luan); try { - PackageLuan.load(luan,"site:/init.luan",null); + init(luan); } catch(LuanException e) { //e.printStackTrace(); - initErr = e; String err = e.getLuanStackTraceString(); logger.error(err); } finally { @@ -121,11 +127,11 @@ rwLock.readLock().lock(); LuanLogger.startThreadLogging(currentLuan); try { - if( initErr != null ) - throw initErr; + init(currentLuan); return service(request,notFound); } catch(LuanException e) { String err = e.getLuanStackTraceString(); + //System.err.println(err); logger.error(err+"\n"+request.rawHead.trim()+"\n"); String msg = "Internel Server Error\n\n" + err; return Response.errorResponse( Status.INTERNAL_SERVER_ERROR, msg );