0

I am using Maven in combination with Quarkus and Angular for my website.

In order to start and stop the Angular frontend with the quarkus backend I have the following plugin set up in my pom.xml:

<plugin>
                <groupId>org.ple</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>3.0.0</version>
                <executions>
                    <execution>
                        <id>frontend</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>sh</executable>
                            <arguments>
                                <argument>-c</argument>
                                <argument>npm run start &amp;&amp; echo &#36;! &gt; ${project.build.directory}/frontend-server.pid</argument>
                            </arguments>
                            <workingDirectory>../../../../../../../frontend/foo/</workingDirectory>
                        </configuration>
                    </execution>

                    <execution>
                    <id>stop-frontend</id>
                    <phase>post-integration-test</phase> 
                    <goals>
                        <goal>exec</goal>
                    </goals>
                    <configuration>
                        <executable>sh</executable>
                        <arguments>
                            <argument>-c</argument>
                            <argument>if [ -f ${project.build.directory}/frontend-server.pid ]; then kill $(cat ${project.build.directory}/frontend-server.pid); fi</argument>
                        </arguments>
                    </configuration>
                </execution>
                </executions>
            </plugin>

During the validation phase the npm run start is executed to start the Angular frontend and the PID is saved to a file so I can later terminate it. The second execution should be called during the post integration phase and kill the process by reading the PID of the frontend process and then killing the process with that PID

The frontend does start but when I close maven using ctrl+c the frontend keeps running until I externally kill the process.

How can I have the frontend be terminated when I terminate maven/quarkus

3
  • What exactly do mean by "the frontend keeps running"? It is a single page application, so once it's loaded it doesn't need anything more from the server, unless for some lazy loading maybe. Commented Jul 9 at 12:43
  • @JSONDerulo Yes, it is a single page application. And I am using quarkus as a backend in combination with maven. When I stop maven the front end website still runs despite the excutable I have set to kill the frontend during the post integration test phase
    – Reewen
    Commented Jul 9 at 12:46
  • 2
    I'd suggest switching to docs.quarkiverse.io/quarkus-quinoa/dev/index.html, rather than hand-rolling your pom.xml and managing the integration of the two by hand. Commented Jul 9 at 14:06

0

Browse other questions tagged or ask your own question.