grails-core icon indicating copy to clipboard operation
grails-core copied to clipboard

stop-app fails when the app has a non-root context-path (in dev environment)

Open rchfox opened this issue 1 year ago • 2 comments

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

  1. Create a simple app project with Grails 4 or 5
$ grails create-app myapp --profile=web
  1. Define a context-path in application.yml
server:
    servlet:
        context-path: /myapp
  1. Run Grails CLI in interactive mode
$ grails
grails> run-app
  1. 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

rchfox avatar Aug 10 '22 05:08 rchfox

Yes, I know the app can be terminated by other means:

  • Just quit the CLI: grails> exit
  • Ctrl+C from the CLI
  • Ctrl+C from gradle bootRun
  • Using the actuator: curl -X POST http://localhost:8080/myapp/actuator/shutdown

However, this seems to be an easy-to-fix bug

rchfox avatar Aug 10 '22 06:08 rchfox

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.

puneetbehl avatar Aug 10 '22 14:08 puneetbehl

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.

puneetbehl avatar Nov 04 '23 20:11 puneetbehl