Giter VIP home page Giter VIP logo

spring-boot-daemon's Introduction

Spring Boot daemon

This project demonstrates how a Spring Boot application can be managed as a service.

Building

You need Java 1.8 and a bash-like shell. To build the project, invoke this command at the root of the project

$ ./mvnw clean install

Unix

A unix distribution is generated automatically and uses jsvc. It is added for demonstration purpose only as Spring Boot 1.3.x has better support for this

Windows

The windows distribution uses winsw.

Warning
You need to install the .NET framework on the target machine first.

To install the sample application as a service, extract the distribution somewhere and open a shell with administrative rights in that directory. Then invoke the following command

$ spring-boot-daemon-sample.exe install
Note

spring-boot-daemon-sample is the identifier of the service. You can control that via Maven properties in the spring-boot-daemon-sample project.

Once the service has been installed, you can start it the usual way, that is:

$ net start spring-boot-daemon-sample

The logs are available in the logs directory of the distribution.

License

Spring Boot Daemon is Open Source software released under the Apache 2.0 license.

spring-boot-daemon's People

Contributors

jlleitschuh avatar michael-simons avatar snicoll avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spring-boot-daemon's Issues

Update for newer (v2) versions of Spring Boot

This solution currently works great with version 1 of Spring Boot, but fails with

Exception in thread "main" java.lang.NoSuchMethodError: org.springframework.boot.SpringApplication.run(Ljava/lang/Object;[Ljava/lang/String;)Lorg/springframework/context/ConfigurableApplicationContext; at net.nicoll.boot.daemon.SpringBootService.start(SpringBootService.java:42) at net.nicoll.boot.daemon.StartSpringBootService.main(StartSpringBootService.java:27)

in version2 ... would it be possible to upgrade / update so it works with v2+ as well?

Dependencies in jar

Do you think, it is possible to pack dependencies in jar instead of lib in this configuration. I mean.. I do this all the time but I wonder, if there is any reason that you have it in lib instead of jar. Thanks.

Gradle Sample?

I see that you have Maven in your examples, would is be possible to have gradle examples as well?

How is the Service User used?

Good Morning,

I have an inquiry about which user is calling java. The documentation leads me to believe that it's the service's "Log on as" account. However, I when start a Spring boot application as a service and its first console line is example.SpringBootApplication : Starting SpringBoootApplication v0.0.1 on [local machine name] with PID 9052 (C:\SpringBootApp\springbootapp-0.0.1\lib\springbootapp-0.0.1.jar started by [local machine name] in C:\SpringBootApp\springbootapp-0.0.1).
[local machine name] does contain a $ at the end of it.
This wouldn't be a concern, however, there are multiple database connections with usernames and passwords. And only as a service, the error log appears for each sqlserver com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user '[local machine name]'. ClientConnectionId:[id], and other databases have invalid user and pass error messages.

My starting xml file was

 <serviceaccount>
    <domain>domain</domain>
     <user>user</user>
     <password>pass</password>
 </serviceaccount>

I've altered it to hard code to Down-Level Logon Name

 <serviceaccount>
     <user>domain\user</user>
     <password>pass</password>
 </serviceaccount>

and to User Principal Name

 <serviceaccount>
     <user>user@domain</user>
     <password>pass</password>
 </serviceaccount>

with the same results.

Here is the full current xml file.

<service>
	<id>@dist.project.id@</id>
	<name>@dist.project.name@</name>
	<description>@dist.project.description@</description>
	<workingdirectory>%BASE%\</workingdirectory>
	<logpath>%BASE%\logs</logpath>
	<logmode>reset</logmode>
	<startmode>manual</startmode>
	<priority>abovenormal</priority>

	<executable>java</executable>

	<startargument>-Dspring.application.admin.enabled=true</startargument>
	<startargument>[email protected]@</startargument>
	<startargument>-Dcom.sun.management.jmxremote.authenticate=false</startargument>
	<startargument>-Dcom.sun.management.jmxremote.ssl=false</startargument>
	<startargument>-jar</startargument>
	<startargument>-Dloader.main=net.nicoll.boot.daemon.StartSpringBootService</startargument>
	<startargument>@dist.jar@</startargument>
	<startargument>@dist.start.class@</startargument>

	<stopexecutable>java</stopexecutable>
	<stopargument>-jar</stopargument>
	<stopargument>-Dloader.main=net.nicoll.boot.daemon.StopSpringBootService</stopargument>
	<stopargument>@dist.jar@</stopargument>
	<stopargument>@dist.jmx.port@</stopargument>

	<onfailure action="restart" delay="30 sec"/>
	<onfailure action="restart" delay="30 sec"/>
	<onfailure action="none" />
	<resetfailure>1 hour</resetfailure>
    
 	<serviceaccount>
		<domain>domain</domain>
		<user>user</user>
		<password>pass</password>
	</serviceaccount>
</service>

Service cannot be stopped properly

i have 3 modules. one of them has just scheduling tasks. another one has jmslisteners and other one has a tcp server socket. module with schedulers can be stopped properly on demand. But other 2 can not be stopped properly. i think connections for tcp socket and activemq block stopping these modules. ?

Improve Documentation Request

docs.spring.io references this project as a Windows Service example, but there isn't a lot of explaination in either docs.spring.io or your README

I'm looking for a breakdown of how this project and it's modules work together in order to fully grokk how such an implementation can be leveraged. The project on it's own works, but not so simple when trying to integrate into an existing project (i.e.; CommandLineRunner)

How to catch stop command?

Is there any way how to catch stop command in spring-boot-daemon-sample? I need to gracefully stop the spring boot app and currently I think it is a force shutdown. Thanks

rename project GroupId

Hi;
can you please rename the project groupId and package (com.example) ?
ex : use com.github
Thanks!

Spring Profiles

Hi,

Is it possible to use Spring Profiles with this implementation? For example, I want to run the service on a QA server with application-qa.properties and on a Production server with application.properites.

Thanks.

Wrong version of winsw in spring-boot-daemon/pom.xml

This version imho does not exist.

            <dependency>
                <groupId>com.sun.winsw</groupId>
                <artifactId>winsw</artifactId>
                <version>1.18</version>
                <classifier>bin</classifier>
                <type>exe</type>
            </dependency>

Probably means

            <dependency>
                <groupId>com.sun.winsw</groupId>
                <artifactId>winsw</artifactId>
                <version>1.8</version>
                <classifier>bin</classifier>
                <type>exe</type>
            </dependency>

JMX process does not start sometimes

WinSW Version, operating system, or hardware.
2.19 to 2.1.2

Operating System
Windows Server 2012, running on a VMware® Workstation 12 Pro.

JVM
1.8.0_101-b13

Framework
Spring-boot 1.5.0 to Spring-boot 2.0.0.M2

Problem description

On normal conditions, when starting the spring-boot application by running the startup-component.bat file, two processes are created:

  • one for the spring-boot application
  • one for the JMX control endpoint

For example, for a component that defines its JMX port as 50204, a netsat to this port, shows:

C:\Program Files\XXX\spring-boot-app>netstat -aon |find /i "listening" |find "50204" TCP 0.0.0.0:50204 0.0.0.0:0 LISTENING 5088 TCP [::]:50204 [::]:0 LISTENING 5088

In this case, the shutdown-component.bat file stops the application correctly.

In some random situations, and using the same exact component, the JMX process does not start, and only the component process is started:

C:\Program Files\XXX\spring-boot-app>netstat -aon |find /i "listening" |find "50204" TCP 0.0.0.0:50204 0.0.0.0:0 LISTENING 2612

In this case, the shutdown-component.bat file does not stops the application, and the only way to stop it is by killing it using "Kill process tree".

Please note that this is an all or nothing situation: if when installed, it starts both processes correctly, it will always be OK. If its not the case, it will never start both processes again.

As mentioned, i'm running this on a VM, and i need to revert the VM's and install new versions (or the same version) every week. In some instantiations, this problem occurs.

I cant find any reason for that, as i always start from the same base snapshot.

Is there anything that i can do to be able to understand why this is happening?

Similar artifact in Maven Central?

I noticed that Maven Central and repo.spring,io have a version of this project deployed with a different groupId and version, but the source code is from this project.

<dependency>
    <groupId>net.kemitix</groupId>
    <artifactId>spring-boot-daemon-integration</artifactId>
    <version>1.1.0</version>
</dependency>

Could you clarify the intended use of this projects artifacts and code, as far as its use ion other projects?
Is "spring-boot-daemon-integration" also intended to be published to Maven Central or SpringIO repositories using the "net.nicoll" groupId and version?
Did you or do you intend for the "spring-boot-daemon-integration" module to be used as a dependency in other projects, or was this just sample code meant to be "copy-pasted" into other projects?
Do you know anything about what/who is publishing the "net.kemitix" artifact (I could not find a publicly forked repository)?

windows installshield2012 complains permission when starting the service

I am using windows install shield 2012 configure the spring-boot-daemon-sample.exe as a windows service. And pass "install" as the parameter to start up the service after installation. However, it reports error 1902, ask for sufficient privilege to start the service.

Any hint for this kind of error ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.