I am running my spring boot application on my server using putty via command
mvn spring-boot:run and it runs only when I have open ssh session. Is it possible to keep application alive after I disconnect session?
Or do I have to make executable war file and deploy to installed tomcat server on my ubunntu 14.04.
I know others ways to deploy boot apps but I want to know if it is possible in my approach.
You can run the command in the background and with nohup like so
nohup mvn spring-boot:run &
When you do this, the application runs in background even after you close ssh session.
In putty, you need to use nohup mvn spring-boot:run > spring-log.txt & to run the command in the background and this generates the spring-log.txt file.
If you don't want console logs to be written (you have logging frameworks which handles the application logs) then use this command
nohup mvn spring-boot:run </dev/null >/dev/null 2>&1 &
BTW, just curious, why are you using mvn spring-boot:run to run your program in your server? doesn't that require you to have maven runtime installed in your server as well?
If you are deploying your executable jar
nohup java -jar <your jar name>
Related
I have an Spring boot web-application with an interactive shell for configuration. I want to run my app as daemon to start server. When I run it normally using java -jar app.jar I get an interactive shell and also I can connect to server using web-browser. but sometimes I want to run it as background on a VPS.
When I run it using nohub with a bash script like following it run but not as daemon and when I close SSH it stop working.
#!/bin/sh
nohup java -jar /web/server.jar &
When I run it as service using ln -s /var/jar-file /etc/init.d/app and call service app start it get error and couldn't run.
When I run it using java -jar app.jar > /var/log/app.log 2>&1 it starts well but by closing the SSH it stop.
You probably have to disable the interactive shell with:
spring.shell.interactive.enabled=false
I am trying to implement a simple cli application ( executable jar file running in linux docker image) using spring-shell library. After i started the Docker image with "docker run -it -p 8080:8080 springshelldemo" command my spring-shell app starts and the cli is available in cmd. How can i access this spring-shell cli from a second cmd using docker exec command (or some other better way) ?
I need this in order to make my app available to more than 1 users at the same time.
I found the answer to this problem. There is this great library on top of spring shell https://github.com/fonimus/ that gives you ssh functionality and with proper docker run file command you can access the spring shell through ssh with all features present.
I want to build and run my Java Maven web app in a docker container. I tried with a following command:
docker run -it --name my_project -v "$PWD":/usr/src/my_project -w /usr/src/my_project maven:3.5.0-jdk-8 mvn clean install tomcat7:run
It correctly copies the resources, run maven clean install (successful build) and run with tomcat7-maven-plugin that is included in my pom.xml.
Everything works fine and logs are really similar to build and run locally on my windows machine:
Unfortunately on a web browser there is information "connection refused".
What could potentially cause the problem?:
- my application is windows specific and cannot run on linux?
- app is fully app and running but something wrong is with proxy configuration or port is not configured?
How can i proceed further - investigate the logs? Try to build on windows docker container?
P.S. I check IP of a container with Kitematic app for windows docker.
Possibly three issues. Once your used -w instead of -v
docker run -it --name my_project -v "$PWD":/usr/src/my_project -w /usr/src/my_project maven:3.5.0-jdk-8 mvn clean install tomcat7:run
Which I assumed was a Typo while posting. Next you didn't publish the port on your machine
docker run -p 9998:9998 -it --name my_project -v "$PWD":/usr/src/my_project -w /usr/src/my_project maven:3.5.0-jdk-8 mvn clean install tomcat7:run
This would map the port 9998 (right side) from your container to the port 9998 on your localhost.
Third and last one, your INFO log says listening on localhost:9998. This is not good. Because that means your war is listening from traffic generated inside the the container only and not from outside the container. You need to configure your war so it listens on all interfaces inside the container and bind should be 0.0.0.0:9998
I am trying to deploy a java web app built using Play.
This link provides a detailed instructions on how to do that.
I successfully managed to follow the instructions to deploy play using the dist command. To run the app I used the command below
play-projects-test-play-1.0-SNAPSHOT/bin/play-projects-test-play
The app is deployed on an Oracle Linux Server release 7.2 which I am connected to through ssh.
However my issue is that when terminating ssh connection would go offline as well. How do I run the it as a service (e.g. service mongod start) ?
You can run the process in background using nohup
nohup ./play-projects-test-play> /dev/null 2>&1 &
Also you can use screen as alternative
screen -A -m -d -S screenname ./play-projects-test-play &
note: you need to install screen
yum install screen
At first let me describe my issue.
I configured Jenkins and after build action I called shell script to run bash script on remote server.
The shell script starts application via command
java -Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=xxx
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-XX:+HeapDumpOnOutOfMemoryError -jar name.jar "BUILD_PARAMETER"
I see logs from my application in Jenkins build, and it's keep build process running. I need to finish it after running
sh run command. Is it possible?
If you're doing this using Jenkins you will need to use the nohup notation as in the comments as well as specifying a non-numerial PID for the process. Jenkins tries to clean up after a job finishes by killing any processes it starts.
BUILD_ID=dontKillMe nohup <-your command -> &
the above command should work
https://wiki.jenkins-ci.org/display/JENKINS/Spawning+processes+from+build
Your shell script need to fork a process, and return, otherwise Jenkins thinks your shell script is still running (which it is, if it's not forking the process and returning).
You have not provided the command you use to launch your application, but a common way to fork a process in linux is:
nohup <your command here> &