-
I'm currently trying to use xodus in combination with kobweb. However, I wasn't able to find a way to free up the acquired xodus instance when the dev build rebuilds the server. Therefore once the dev rebuild is done the xodus connection cannot be reacquired, because the instance wasn't closed properly (basically a form of file locking occurs). Shutting down kobweb and rerunning does work though. Is there any functionality available in kobweb, which would allow to free up resource on shutdown/rebuild, I am not aware off? If not, I guess it would be convenient to have the analog to the @ApiInit annotation, maybe @ApiCleanup that gets called when the server rebuilds or get shutdown. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 7 replies
-
Great question. The three places I can think to put cleanup logic are
Can you share a bit with me how you'd ideally release the instance? Is it something you'd rather do outside the server code (so, Gradle) or should it be inside the server code as it needs to have access to some data value in there (e.g. the inverse of something you set in an |
Beta Was this translation helpful? Give feedback.
-
I know tested the proposal from above and it would work splendidly for my use case. I can still use my xodus database even after the dev server reloads the api.jar. I made a pull request #352 with a preliminary implementation, that currently only calls the dispose callback for the case when the dev server reloads the jar, but not when the server shutdown. I felt those changes would need to be a bit bigger, than what I have added so I left this part open. |
Beta Was this translation helpful? Give feedback.
-
Good morning. I just woke up, and after sleeping on it, I think this is worth putting in, even if it needs to be documented carefully. As you point out in your case, it can at least be useful for development. I also thought we might not even need to create a new dispose annotation if we just pass an extra field into the init context. Imagine code like this: @InitApi
fun initStuff(ctx) {
// Option 1 - another ctx property
ctx.onDispose { ... }
// Option 2 - add to data
ctx.data.onDispose { ... }
// Option 3 - create new events property
// Only one event so far but maybe more later?
ctx.events.onDispose { ... }
} I'm not suggesting you change your PR, I'm just thinking out loud and curious what you think about this approach overall and the specific options. |
Beta Was this translation helpful? Give feedback.
-
Please have a look at the new pull request #353. What do you think about the implementation? |
Beta Was this translation helpful? Give feedback.
Please have a look at the new pull request #353. What do you think about the implementation?