最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

windows services - Apache Procrun Failed to stop Spring boot fat jar - Stack Overflow

matteradmin3PV0评论

I am trying to setup a window service out of a spring boot fat jar using Apache Procrun. application is started successfully. But when I tried to stop the application by stopping the Windows service, it did not work. Spring boot 3.1.5 and 1.4.0.0 is the Apache procrun version.

Error logs from Apache Procurn :

[2024-11-17 21:06:45] [info]  [20720] Service SERVICE_CONTROL_STOP signalled.
[2024-11-17 21:06:45] [info]  [12804] Stopping service...
[2024-11-17 21:06:45] [error] [12804] Missing service ImageFile.
[2024-11-17 21:06:45] [error] [12804] The parameter is incorrect.

Procurn .bat :

@echo off

rem Set the path to the Java runtime
set JAVA_HOME=C:\Program Files\Java\jdk-21.0.1

rem Set the classpath for your Java application
set CLASSPATH=E:\USER\Other\Windows-service-R-D\sample.jar

rem Install the service using prunsrv
prunsrv //IS//XX ^
    --Description "My Java Windows Service" ^
    --Install "E:\USER\Other\Windows-service-R-D\prunsrv.exe" ^
    --Jvm "%JAVA_HOME%\bin\server\jvm.dll" ^
    --StartMode=jvm ^
    --StartClass=.springframework.boot.loader.JarLauncher ^
    --StartMethod main ^
    --StopMode exe ^
    --StopPath=E:\USER\Other\Windows-service-R-D\StopService.bat ^
    --Classpath "%CLASSPATH%" ^
    --LogPath="E:\USER\Other\Windows-service-R-D" ^
    --LogPrefix=myapp ^
    --Startup auto ^
    --StdOutput "E:\USER\Other\Windows-service-R-D\stdout.txt" ^
    --StdError "E:\USER\Other\Windows-service-R-D\stderr.txt"

StopService.bat:

@echo off
rem Use PowerShell to make a POST request
powershell -Command "Invoke-WebRequest -Uri http://localhost:7310/Sample/tf/turnOff -Method POST"

And I am able to stop my spring boot application by calling this StopService.bat from a cmd and PowerShell.

Post a comment

comment list (0)

  1. No comments so far