grails-core
grails-core copied to clipboard
stop-app fails when the app has a non-root context-path (in dev environment)
Expected Behavior
grails> stop-app | Shutting down application... | Application shutdown.
Actual Behaviour
grails> stop-app Shutting down application... | Error Application not running
grails> stop-app --stacktrace | Shutting down application... | Error Application not running
java.io.FileNotFoundException: http://localhost:8080/actuator/shutdown
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at stop-app.run(stop-app.groovy:86)
at org.grails.cli.profile.commands.script.GroovyScriptCommand.handle(GroovyScriptCommand.groovy:153)
at org.grails.cli.profile.AbstractProfile.handleCommand(AbstractProfile.groovy:475)
at org.grails.cli.GrailsCli.handleCommand(GrailsCli.groovy:377)
at org.grails.cli.GrailsCli$_handleCommandWithCancellationSupport_closure6.doCall(GrailsCli.groovy:468)
Note that the context-path
is missing in the URI /actuator/shutdown
Steps To Reproduce
- Create a simple app project with Grails 4 or 5
$ grails create-app myapp --profile=web
- Define a context-path in application.yml
server:
servlet:
context-path: /myapp
- Run Grails CLI in interactive mode
$ grails
grails> run-app
- Try to shutdown the app
grails> stop-app
Environment Information
- Operating System: Ubuntu 22.04.1 LTS
- JDK version: OpenJDK 11.0.12
- Grails: 5.2.2
- Gradle: 7.2 Also happens with:
- Grails: 4.1.1
- Gradle: 5.6.4
Example Application
No response
Version
4.1.1 and 5.2.2
Yes, I know the app can be terminated by other means:
- Just quit the CLI:
grails> exit
-
Ctrl+C
from the CLI -
Ctrl+C
fromgradle bootRun
- Using the actuator:
curl -X POST http://localhost:8080/myapp/actuator/shutdown
However, this seems to be an easy-to-fix bug
Personally, I don't use stop-app
for the last few years. But, if you feel this is a quick fix please feel free to send a PR and I will try to merge it quickly.
We have moved away from the legacy Grails Scripts and with the New Grails CLI. Instead, we leverage the Gradle build system for greater flexibility and a more cohesive development environment.