Skip to content

Commit

Permalink
feat: allow running updater as one-off job
Browse files Browse the repository at this point in the history
  • Loading branch information
m90 committed Dec 4, 2023
1 parent 70560ab commit 8e59a4a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
13 changes: 1 addition & 12 deletions runUpdateWbStack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,4 @@ set -e
# Call runUpdate with all of the magic stuff that is in there for logging and JVM etc
# But don't actually pass any real arguments into Java
# Also pass in our custom Main class that will handle the "magic"
# TODO also pass class path in...
./runUpdate.sh \
-m org.wikidata.query.rdf.tool.WbStackUpdate \
-h IGNOREDHOST \
-n IGNOREDNAMESPACE \
-- \
--wikibaseHost IGNOREDWIKIBASEHOST \
--wikibaseScheme IGNOREDSCHEME \
--conceptUri IGNOREDCONCEPTURI \
--entityNamespaces IGNOREDENTITYNS \
--ids IGNOREDIDS

./runUpdate.sh -m org.wikidata.query.rdf.tool.WbStackUpdate
12 changes: 12 additions & 0 deletions src/main/java/org/wikidata/query/rdf/tool/WbStackUpdate.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public final class WbStackUpdate {
private static String wbStackWikibaseScheme;
private static int wbStackLoopLimit;
private static String wbStackProxyMapIngress;
private static boolean wbStackRunUpdaterAsJob;

// Globally reused services and objects
private static Gson gson;
Expand Down Expand Up @@ -114,6 +115,7 @@ private static void setValuesFromEnvOrDie() {
wbStackUpdaterNamespaces = System.getenv().getOrDefault("WBSTACK_UPDATER_NAMESPACES", "120,122,146");
wbStackWikibaseScheme = System.getenv().getOrDefault("WBSTACK_WIKIBASE_SCHEME", "https");
wbStackLoopLimit = Integer.parseInt(System.getenv("WBSTACK_LOOP_LIMIT"));
wbStackRunUpdaterAsJob = Boolean.parseBoolean(System.getenv("WBSTACK_RUN_UPDATER_AS_JOB"));
}

private static void setSingleUseServicesAndObjects() {
Expand All @@ -131,6 +133,16 @@ public static void main(String[] args) throws InterruptedException, IOException
setValuesFromEnvOrDie();
setSingleUseServicesAndObjects();

if (wbStackRunUpdaterAsJob) {
boolean success = runUpdaterWithArgs(args);
closeSingleUseServicesAndObjects();
if (!success) {
System.err.println("Failed to run update job.");
System.exit(1);
}
return;
}

int loopCount = 0;
long apiLastCalled;

Expand Down

0 comments on commit 8e59a4a

Please sign in to comment.