Has anyone tried the instant start JVM feature <CR...
# ktor
s
Has anyone tried the instant start JVM feature CRaC with ktor yet?
👀 2
l
Hi @spierce7 do you try with CRaC on ktor?
s
I have not. I am reasonably confident it would work though.
l
searching for examples I didn't find any, only with spring
s
It should be the same process for both
l
But seems the spring guys did something https://docs.spring.io/spring-framework/reference/integration/checkpoint-restore.html ... some kind of shortcut with org.crac.resource interface implementation on beans
s
You mean
When the
-Dspring.context.checkpoint=onRefresh
JVM system property is set, a checkpoint is created automatically at startup during the
LifecycleProcessor.onRefresh
phase. After this phase has completed, all non-lazy initialized singletons have been instantiated, and
InitializingBean#afterPropertiesSet
callbacks have been invoked; but the lifecycle has not started, and the
ContextRefreshedEvent
has not yet been published.
This looks like all they are doing
Copy code
public static final String CHECKPOINT_PROPERTY_NAME = "spring.context.checkpoint";
private static final boolean checkpointOnRefresh =
			ON_REFRESH_VALUE.equalsIgnoreCase(SpringProperties.getProperty(CHECKPOINT_PROPERTY_NAME));	

	if (checkpointOnRefresh) {
		new CracDelegate().checkpointRestore();
	}
Take a look at what they are doing. This seems super easy to replicate.
l
Yes sounds easy to replicate, the doubt I keep is about the server itself, there is a specific topic talking about must be 0 connection in activity.
s
that seems reasonable
connections wouldn't be able to restore
but that's also easy to control I think
l
Shutdown the server is easy yes, but you need to shutdown only the server connections and keep the server/JVM ON, so you can resume again in this state. This is far I understood 😄
s
I mean, your goal is to start up the app, create a restore checkpoint, and then kill the process, or, I'm not sure exactly how it works
l
Yes exactly, but what I read told this part about stop the active connections, this is a must