Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ApplicationPidFileWriter doesn't produce .pid file on Spring Boot

Tags:

spring-boot

The following setup doesn't seem to generate .pid file (as described here - http://www.kubrynski.com/2014/05/managing-spring-boot-application.html:

public static void main(String[] args) {
        SpringApplication app = new SpringApplication(BrokerFeedApplication.class);
        app.addListeners(new ApplicationPidFileWriter());
        app.run(BrokerFeedApplication.class, args);
    }
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.2.5.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

What am I missing?

like image 833
Simeon Leyzerzon Avatar asked Jul 24 '15 20:07

Simeon Leyzerzon


1 Answers

By using the static run(Object source, String... args) method in the last line you're disregarding the app configuration you did in the first two lines. See Javadoc (emphasis mine):

Static helper that can be used to run a SpringApplication from the specified source using default settings.

Change the last line to use the run(java.lang.String...) instance method to make use the previously registered listener, i.e. change:

app.run(DemoApplication.class, args);

to

app.run(args);
like image 200
kryger Avatar answered Nov 12 '22 14:11

kryger