-//#! /usr/bin/java --source 17 -cp /usr/local/share/a2/osgi/equinox/org.argeo.tp.osgi/org.eclipse.osgi.3.18.jar:/usr/local/share/a2/org.argeo.cms/org.argeo.init.2.3.jar -Dosgi.configuration.cascaded=true -Dosgi.sharedConfiguration.area=/etc/freed -Dosgi.sharedConfiguration.area.readOnly=true -Dosgi.configuration.area=/var/lib/freed/state/ -Dosgi.instance.area=/var/lib/freed/data/ -Dorg.osgi.framework.system.packages.extra=sun.security.internal.spec,sun.security.provider,com.sun.net.httpserver,com.sun.jndi.ldap,com.sun.jndi.ldap.sasl,com.sun.jndi.dns,com.sun.security.jgss,com.sun.nio.file,com.sun.nio.sctp -Dorg.eclipse.equinox.http.jetty.autostart=false
-
-import java.lang.management.ManagementFactory;
-
-import org.argeo.init.Service;
-
-import jdk.jshell.tool.JavaShellToolBuilder;
-import sun.misc.Signal;
-
-public class FREEdInit {
- public static void main(String... args) {
- final long pid = ProcessHandle.current().pid();
- System.out.println("FREEd Init daemon starting with pid " + pid + "...");
-// System.out.println(System.getProperty("user.dir"));
-// System.out.println(System.getProperty("user.name"));
-// System.out.println(System.getProperty("user.home"));
- System.out.flush();
-
- Signal.handle(new Signal("TERM"), (signal) -> {
- System.out.println("SIGTERM caught");
- System.exit(0);
- });
- Signal.handle(new Signal("INT"), (signal) -> {
- System.out.println("SIGINT caught");
- System.exit(0);
- });
- Signal.handle(new Signal("HUP"), (signal) -> {
- System.out.println("SIGHUP caught");
- System.exit(0);
- });
-
- if (args.length > 0 && ("1".equals(args[0]) //
- || "single".equals(args[0]) //
- || "emergency".equals(args[0]))) {
- // TODO check if we can remove dependency to management
- String classpath = ManagementFactory.getRuntimeMXBean().getClassPath();
- String feedbackMode = "concise";
- // TODO --startup script
- JavaShellToolBuilder builder = JavaShellToolBuilder.builder();
- try {
- builder.start("--execution", "direct", "--class-path", classpath, "--feedback", feedbackMode);
- } catch (Exception e) {
- e.printStackTrace();
- System.err.flush();
- System.exit(1);
- return;
- }
-
- } else {
- Service.main(args);
- }
- }
-}