From: Mathieu Baudier Date: Fri, 1 May 2020 09:25:43 +0000 (+0200) Subject: Call java directly in systemd instance units. X-Git-Tag: argeo-commons-2.1.89~141 X-Git-Url: https://git.argeo.org/?p=lgpl%2Fargeo-commons.git;a=commitdiff_plain;h=2d8a1995232d2a7e3333453b052fe1f39b0d1a25 Call java directly in systemd instance units. --- diff --git a/dist/argeo-node/rpm/usr/lib/systemd/system/argeo.service b/dist/argeo-node/rpm/usr/lib/systemd/system/argeo.service index 8d8c261d7..1cdb7c23d 100644 --- a/dist/argeo-node/rpm/usr/lib/systemd/system/argeo.service +++ b/dist/argeo-node/rpm/usr/lib/systemd/system/argeo.service @@ -7,6 +7,7 @@ Wants=postgresql.service Type=simple ExecStart=/usr/sbin/argeoctl start ExecReload=/usr/sbin/argeoctl reload +SuccessExitStatus=143 [Install] WantedBy=multi-user.target diff --git a/dist/argeo-node/rpm/usr/lib/systemd/system/argeo@.service b/dist/argeo-node/rpm/usr/lib/systemd/system/argeo@.service index 14c2ecdb3..cbfd41ce3 100644 --- a/dist/argeo-node/rpm/usr/lib/systemd/system/argeo@.service +++ b/dist/argeo-node/rpm/usr/lib/systemd/system/argeo@.service @@ -5,17 +5,22 @@ Wants=postgresql.service [Service] Type=simple -ExecStart=/usr/sbin/argeoctl start %I -ExecReload=/usr/sbin/argeoctl reload %I DynamicUser=true StateDirectory=argeo.d/%I LogsDirectory=argeo.d/%I ConfigurationDirectory=argeo.d/%I +WorkingDirectory=/var/lib/argeo.d/%I -# Workaround to pass locations for systemd with version < 240 -Environment=INSTANCE_DIR=/var/lib/argeo.d/%I CONF_DIR=/etc/argeo.d/%I -#Environment="INSTANCE_DIR=$STATE_DIRECTORY" "CONF_DIR=$CONFIGURATION_DIRECTORY" -PassEnvironment=INSTANCE_DIR CONF_DIR +ExecStart=/usr/lib/jvm/jre-11/bin/java \ + -Dlog4j.configuration="file:/etc/argeo.d/%I/log4j.properties" \ + @/etc/argeo.d/%I/jvm.args \ + @/usr/share/osgi/boot/framework.args \ + -configuration /var/lib/argeo.d/%I/state \ + -data /var/lib/argeo.d/%I/data +#ExecReload=/usr/sbin/argeoctl reload %I +# Exit codes of the JVM when SIGTERM or SIGINT have been caught: +SuccessExitStatus=143 130 +#ExecStopPost=/usr/bin/cat "$EXIT_STATUS" > /var/lib/argeo.d/%I/state/EXIT_STATUS [Install] WantedBy=multi-user.target diff --git a/dist/osgi-boot/pom.xml b/dist/osgi-boot/pom.xml index 996a3e60d..a2ad00a6b 100644 --- a/dist/osgi-boot/pom.xml +++ b/dist/osgi-boot/pom.xml @@ -99,6 +99,22 @@ + + /usr/share/osgi/boot + root + root + 644 + noreplace + false + + + rpm/usr/share/osgi/boot + + *.args + + + + osgi-boot-equinox diff --git a/dist/osgi-boot/rpm/usr/share/osgi/boot/framework.args b/dist/osgi-boot/rpm/usr/share/osgi/boot/framework.args new file mode 100644 index 000000000..1c1d2fac8 --- /dev/null +++ b/dist/osgi-boot/rpm/usr/share/osgi/boot/framework.args @@ -0,0 +1 @@ +-jar /usr/share/osgi/boot/org.eclipse.osgi.jar \ No newline at end of file diff --git a/org.argeo.osgi.boot/src/org/argeo/osgi/boot/OsgiBoot.java b/org.argeo.osgi.boot/src/org/argeo/osgi/boot/OsgiBoot.java index 38da0479f..666a5aadc 100644 --- a/org.argeo.osgi.boot/src/org/argeo/osgi/boot/OsgiBoot.java +++ b/org.argeo.osgi.boot/src/org/argeo/osgi/boot/OsgiBoot.java @@ -19,6 +19,7 @@ import static org.argeo.osgi.boot.OsgiBootUtils.debug; import static org.argeo.osgi.boot.OsgiBootUtils.warn; import java.io.File; +import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; @@ -114,8 +115,9 @@ public class OsgiBoot implements OsgiBootConstants { } else { for (String source : sources.split(",")) { if (source.trim().equals(A2Source.DEFAULT_A2_URI)) { - provisioningManager - .registerSource(A2Source.SCHEME_A2 + "://" + homePath.toString() + "/.local/share/osgi"); + if (Files.exists(homePath)) + provisioningManager.registerSource( + A2Source.SCHEME_A2 + "://" + homePath.toString() + "/.local/share/osgi"); provisioningManager.registerSource(A2Source.SCHEME_A2 + ":///usr/local/share/osgi"); provisioningManager.registerSource(A2Source.SCHEME_A2 + ":///usr/share/osgi"); } else {