Call java directly in systemd instance units.
authorMathieu Baudier <mbaudier@argeo.org>
Fri, 1 May 2020 09:25:43 +0000 (11:25 +0200)
committerMathieu Baudier <mbaudier@argeo.org>
Fri, 1 May 2020 09:25:43 +0000 (11:25 +0200)
dist/argeo-node/rpm/usr/lib/systemd/system/argeo.service
dist/argeo-node/rpm/usr/lib/systemd/system/argeo@.service
dist/osgi-boot/pom.xml
dist/osgi-boot/rpm/usr/share/osgi/boot/framework.args [new file with mode: 0644]
org.argeo.osgi.boot/src/org/argeo/osgi/boot/OsgiBoot.java

index 8d8c261d7700beb72a9792f99b0d38029c027827..1cdb7c23d4c18acbf2cc0a11878bdf7c0593c9f5 100644 (file)
@@ -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
index 14c2ecdb3ab9ed1ae6ff01c6013961072bbb6c8d..cbfd41ce373e594b4550d0f9452d78cd03cc9f15 100644 (file)
@@ -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
index 996a3e60d9f15575235a46c4095a148fefa8dfee..a2ad00a6b303f463622690c1d14922251cb2b1d4 100644 (file)
                                                                                                </includes>
                                                                                        </dependency>
                                                                                </mapping>
+                                                                               <mapping>
+                                                                                       <directory>/usr/share/osgi/boot</directory>
+                                                                                       <username>root</username>
+                                                                                       <groupname>root</groupname>
+                                                                                       <filemode>644</filemode>
+                                                                                       <configuration>noreplace</configuration>
+                                                                                       <directoryIncluded>false</directoryIncluded>
+                                                                                       <sources>
+                                                                                               <source>
+                                                                                                       <location>rpm/usr/share/osgi/boot</location>
+                                                                                                       <includes>
+                                                                                                               <include>*.args</include>
+                                                                                                       </includes>
+                                                                                               </source>
+                                                                                       </sources>
+                                                                               </mapping>
                                                                        </mappings>
                                                                        <requires>
                                                                                <require>osgi-boot-equinox</require>
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 (file)
index 0000000..1c1d2fa
--- /dev/null
@@ -0,0 +1 @@
+-jar /usr/share/osgi/boot/org.eclipse.osgi.jar
\ No newline at end of file
index 38da0479f6d5579742f9d00c655c35fd2c254416..666a5aadcd00ccb2d12ac48bc8822978912cc45a 100644 (file)
@@ -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 {