Check an application's timeout

Hey is there something I can call in Lucee’s inner workings to see how much time out an application has left?

EG: we’re using the default one day timeout for applications. I want to check how far through that 24h period an idling application currently is.

I know I can heath-robinson something by sticking a timestamped variable in the application scope and spy on that. This is not what I am asking about. I’m wanting to check Lucee’s own application timeout mechanism. IE: Lucee must be able to find out what the status is, given it will expire the app after the 24h period.

Cheers.

1 Like

There may be a simpler way, but this appears to work, with the obvious proviso that you shouldn’t call it from the app you’re trying to observe as it will just reset the timeout.

numeric function appSecondsUntilTimeout( required string appName, required string luceeAdminPassword ){
	var configs = GetPageContext().getConfig().getConfigServer( arguments.luceeAdminPassword ).getConfigWebs()
	var totalContexts = ArrayLen( configs )
	cfloop( from=1, to=totalContexts, index="local.i" ){
		var scopeContext = configs[ i ].getFactory().getScopeContext()
		var app = scopeContext.getExistingApplicationScope( arguments.appName )
		if( IsNull( app ) )
			continue;
		var expires = ( app.getLastAccess() + app.getTimeSpan() )
		var millisecondsLeft = ( expires - GetTickCount() )
		return Round( millisecondsLeft/1000 )
	}
	Throw( message: "Can't find an app called '#arguments.appName#'" )
}
Dump( appSecondsUntilTimeout( "myApp", server.system.environment.LUCEE_ADMIN_PASSWORD ) )
4 Likes

Exactly what I was looking for, thanks!

Where’d you get that knowledge from, btw? Just poking around at stuff?

1 Like

We have an internal app which monitors certain aspects of other apps running on the same server so I just lifted some of the code and played with it, while also glancing at the Lucee source.

2 Likes