Adam Cameron
Adam Cameron
timeInMillisecondsAtStartup = CreateObject("java", "lucee.loader.engine.CFMLEngineFactory").getInstance().uptime()
timeInMillisecondsNow = getTickCount()
uptimeInMilliseconds = timeInMillisecondsNow - timeInMillisecondsAtStartup
uptimeInMillisecondsAsDuration = convertMillisecondsToDuration(uptimeInMilliseconds)
writeOutput(uptimeInMillisecondsAsDuration)
function convertMillisecondsToDuration(ms) {
var s = int(ms / 1000)
var m = int(s / 60)
var h = int(m / 60)
var d = int(h / 24)
return
"#numberFormat(d, "00")#"
& ":#numberFormat(h % 24, "00")#"
& ":#numberFormat(m % 60, "00")#"
& ":#numberFormat(s % 60, "00")#"
}
This outputs something like 23:11:57:09
90% of the time it works fine. Periodically, it will return a much lower value, eg 00:00:12:56
Then it will return to emitting the correct value
We see this after an application reload (just running onApplicationStart directly, not an actual "app restart"). However this could be confirmation bias at work: we have two pieces of code running this, one ad hoc (always correct), one as part of the code that runs from onApplicationStart running; if it reports wrong, it's always the latter that does it, but the latter doesn't always do it.
If after seeing it wrong on the app-start code, I check the ad-hoc code, it's still reporting wrong.
It is not some wayward var scoping issue; the code seems sound to me.
We have only one Lucee instance in the container.
We see it happening on multiple single-instance-Lucee-containers (ie: it's not just one isolated box doing it). All of these containers are running the same Docker image / codebase.
Any ideas what might be going on? Does this ring any bells with anyone?
Don't sink any time into investigating, I can do that, I am just checking if anyone already knows "ah yeah that happens cos x" (long odds on that I know).
Cheers.dswitzer
02/02/2023, 1:55 PMAdam Cameron
dswitzer
02/02/2023, 1:58 PMdswitzer
02/02/2023, 1:59 PMdswitzer
02/02/2023, 2:01 PMAdam Cameron
Adam Cameron
uptime in the the trycf gist, but it's:
/*
* <https://github.com/lucee/Lucee/blob/5.3.9.166/core/src/main/java/lucee/runtime/engine/CFMLEngineImpl.java#L410>
* this.uptime = System.currentTimeMillis();
*
* <https://github.com/lucee/Lucee/blob/5.3.9.166/core/src/main/java/lucee/runtime/engine/CFMLEngineImpl.java#L1612-L1614>
* public long uptime() {
* return uptime;
* }
*/
Thanks for the tip re .getRuntimeMXBean().getUptime(). This is more what I'd want us to use anyhow (I inherited this code).dswitzer
02/02/2023, 3:19 PM