Closed runarmyklebust closed 6 years ago
We should prioritize this; its a simple task that would be very useful
If it is a really small thing, we don't need "PAB" Approval. Which library would you put this in?
@runarmyklebust I need this in app-cronjob by next wednesday! :) So that a cronjob is only executed on the master node.
I think cronjobs are only running on master already!
It's built into the library
Documentation says otherwise? https://github.com/enonic/app-cronjob/blame/master/README.md#L8-L9
Either: a) Sten Roger never fixed so it only runs on master (as we agreed) or b) It is not documented correctly
Anyway, an isMaster function is useful - Im just curious how to access this information?
I wonder if a workaround would be to install the app on a single node only. Aka $XP_HOME/deploy not toolbox install-app. Not very pretty in prod though?
Seems to be what Sten Roger is hinting to in the doc.
or we can create a tiny java-lib for this as a workaround
Installing an app locally is currently "not" possible from application admin. Which means the third party OPS provider has to get involved... :(
So yes a tiny-java-lib would be lovely. (or just "inlined" in app-cronjob)
Deploying to a single node is perfectly fine if that is what you need...
@runarmyklebust will there be time to make the tiny java code snippet today or tomorrow?
yes
@runarmyklebust I'm guessing isMaster() could be called here https://github.com/enonic/app-cronjob/blob/master/src/main/java/com/enonic/app/cronjob/runner/JobRunnerImpl.java#L30
Or maybe the sceduler should not even be running unless isMaster.
So @runarmyklebust, you do the snippet for @ComLock We will create a function "isMaster" in a proper new library "cluster"
Where is this library now? How can I add it to my project?
The library is treated the same way as the other XP libraries.
Library in the repo: http://repo.enonic.com/public/com/enonic/xp/lib-cluster/6.15.0-RC1/ Documentation: http://repo.enonic.com/public/com/enonic/xp/docs/6.15.0-RC1/docs-6.15.0-RC1-libdoc.zip!/module-cluster.html
You include it the same way you include other libraries:
include 'com.enonic.xp:lib-cluster:6.15.0-RC1'
The isMaster function in IndexService would be useful to expose in js-api also.
Not sure about where to place it, maybe a new "system" lib? Could also expose other stuff like "hostname" etc