Search in sources :

Example 1 with ApplicationPidFileWriter

use of org.springframework.boot.context.ApplicationPidFileWriter in project testsigma by testsigmahq.

the class TestsigmaWebApplication method main.

public static void main(String[] args) {
    try {
        System.setProperty("com.sun.security.enableAIAcaIssuers", "true");
        SpringApplication application = new SpringApplication(TestsigmaWebApplication.class);
        application.addListeners(new ApplicationPidFileWriter("./bin/app.pid"));
        application.run();
    } catch (Throwable t) {
        t.printStackTrace();
    }
}
Also used : SpringApplication(org.springframework.boot.SpringApplication) ApplicationPidFileWriter(org.springframework.boot.context.ApplicationPidFileWriter)

Example 2 with ApplicationPidFileWriter

use of org.springframework.boot.context.ApplicationPidFileWriter in project ontrack by nemerosa.

the class Application method main.

/**
 * Start-up point
 *
 * @param args Arguments passed to the program, they may contain configuration variables.
 */
public static void main(String[] args) {
    // PID file
    File pid = new File("ontrack.pid");
    // Runs the application
    SpringApplication application = new SpringApplication(Application.class);
    application.addListeners(new ApplicationPidFileWriter(pid));
    application.run(args);
}
Also used : SpringApplication(org.springframework.boot.SpringApplication) ApplicationPidFileWriter(org.springframework.boot.context.ApplicationPidFileWriter) File(java.io.File)

Example 3 with ApplicationPidFileWriter

use of org.springframework.boot.context.ApplicationPidFileWriter in project openpos-framework by JumpMind.

the class OpenposManagementServer method main.

public static void main(String[] args) throws Exception {
    System.out.println("OpenposManagementServer working dir: " + System.getProperty("user.dir"));
    invokeOptionalStartupClass();
    SpringApplication application = new SpringApplication(OpenposManagementServer.class);
    application.addListeners(new ApplicationPidFileWriter());
    application.run(args);
}
Also used : SpringApplication(org.springframework.boot.SpringApplication) ApplicationPidFileWriter(org.springframework.boot.context.ApplicationPidFileWriter)

Example 4 with ApplicationPidFileWriter

use of org.springframework.boot.context.ApplicationPidFileWriter in project SpringBootSample by heowc.

the class SpringBootGracefulShutdownApplication method main.

public static void main(String[] args) {
    SpringApplication application = new SpringApplicationBuilder().sources(SpringBootGracefulShutdownApplication.class).listeners(new ApplicationPidFileWriter("./application.pid")).build();
    application.run(args);
}
Also used : SpringApplication(org.springframework.boot.SpringApplication) SpringApplicationBuilder(org.springframework.boot.builder.SpringApplicationBuilder) ApplicationPidFileWriter(org.springframework.boot.context.ApplicationPidFileWriter)

Example 5 with ApplicationPidFileWriter

use of org.springframework.boot.context.ApplicationPidFileWriter in project modeldb by VertaAI.

the class ServiceSet method startSpringServer.

private static void startSpringServer() {
    var path = System.getProperty(CommonConstants.USER_DIR) + "/" + ModelDBConstants.BACKEND_PID;
    try {
        File pidFile = new File(path);
        if (pidFile.exists()) {
            try (BufferedReader reader = new BufferedReader(new FileReader(pidFile))) {
                String pidString = reader.readLine();
                var pid = Long.parseLong(pidString);
                var process = ProcessHandle.of(pid);
                if (process.isPresent()) {
                    var processHandle = process.get();
                    LOGGER.warn("Port is already used by modeldb_backend PID: {}", pid);
                    boolean destroyed = processHandle.destroy();
                    LOGGER.warn("Process kill completed `{}` for PID: {}", destroyed, pid);
                    processHandle = processHandle.onExit().get();
                    LOGGER.warn("Process is alive after kill: `{}`", processHandle.isAlive());
                }
            }
        }
        SpringApplication application = new SpringApplication(App.class);
        application.addListeners(new ApplicationPidFileWriter(path));
        application.run();
    } catch (Exception e) {
        throw new ModelDBException(e);
    }
}
Also used : ModelDBException(ai.verta.modeldb.common.exceptions.ModelDBException) SpringApplication(org.springframework.boot.SpringApplication) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) ApplicationPidFileWriter(org.springframework.boot.context.ApplicationPidFileWriter) File(java.io.File) IOException(java.io.IOException) ModelDBException(ai.verta.modeldb.common.exceptions.ModelDBException)

Aggregations

SpringApplication (org.springframework.boot.SpringApplication)13 ApplicationPidFileWriter (org.springframework.boot.context.ApplicationPidFileWriter)13 File (java.io.File)3 ModelDBException (ai.verta.modeldb.common.exceptions.ModelDBException)1 BufferedReader (java.io.BufferedReader)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 SpringBootApplication (org.springframework.boot.autoconfigure.SpringBootApplication)1 SpringApplicationBuilder (org.springframework.boot.builder.SpringApplicationBuilder)1 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)1