sab123
sab123

Reputation: 11

Steps to run Spring Boot application as Windows service using winsw

How do I run Spring Boot Application as Windows Service, as I'm following spring doc for winsw.
Steps:

  1. I downloaded distribution package.
  2. Downloaded binary that is winsw.1.19.exe.

And next they are asking to replace winsw.exe to myApp.exe and in installation guide they mention I need to edit configuration file, but I'm not getting where is the configuration file where I need to make changes.

Note: already I have my Spring Boot application is working as service I need to run this service as Windows service.

Upvotes: 0

Views: 15506

Answers (1)

Dimitri Mestdagh
Dimitri Mestdagh

Reputation: 44725

The winsw documentation mentions what this configuration file is while the documentation you're referring to also shows an example of how to use it.

The idea is the following, you rename the executable to myApp.exe and you create an XML configuration file called myApp.xml. I usually configure the service like this (even though it's a bit different from the spring sample):

<service>
    <id>windowsServiceId</id> <!-- Change this -->
    <name>Readable name of the windows service</name><!-- Change this -->
    <description>Description of the windows service</description><!-- Change this -->
    <workingdirectory>%BASE%\</workingdirectory>
    <logpath>%BASE%\logs</logpath>

    <executable>java</executable>
    <arguments>-jar my-application.jar</arguments><!-- Change this -->
</service>

If you have both in place, you can run the following command to install the windows service:

myApp.exe install

Upvotes: 9

Related Questions