From 8e59a4ae31900ccd025d4e49acbc41d3515d630f Mon Sep 17 00:00:00 2001 From: Frederik Ring Date: Mon, 4 Dec 2023 10:00:00 +0100 Subject: [PATCH] feat: allow running updater as one-off job --- runUpdateWbStack.sh | 13 +------------ .../org/wikidata/query/rdf/tool/WbStackUpdate.java | 12 ++++++++++++ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/runUpdateWbStack.sh b/runUpdateWbStack.sh index d43c061..1b8d342 100755 --- a/runUpdateWbStack.sh +++ b/runUpdateWbStack.sh @@ -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 diff --git a/src/main/java/org/wikidata/query/rdf/tool/WbStackUpdate.java b/src/main/java/org/wikidata/query/rdf/tool/WbStackUpdate.java index eef22d2..13eeefb 100644 --- a/src/main/java/org/wikidata/query/rdf/tool/WbStackUpdate.java +++ b/src/main/java/org/wikidata/query/rdf/tool/WbStackUpdate.java @@ -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; @@ -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() { @@ -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;