0

I want to deploy my java spring backend to AWS . I figured the way to deploy jar file on aws. But the problem is as soon as I terminate the terminal deployment stops. I created a jar file on build and hosted on aws EC2 linux Instance by copying jar file there and running below command .

java -jar jarfile

I want this deployment to be persistent. Is there any tool similar to pm2 for nodeJs in JAVA so that I can run this jar file permanently. ?

Thanks for help.

Harshit kyal
  • 365
  • 1
  • 5
  • 24
  • You can use javaw -jar jarfile or this [https://stackoverflow.com/a/12108646/4986530](https://stackoverflow.com/a/12108646/4986530) – Ryan Guamos May 02 '20 at 11:29
  • Any details on how hosing? Beanstalk does [support](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_Java.html) java applications for instance. Or you are planying to use self-managed ec2 instance? – Marcin May 02 '20 at 11:32
  • @Marcin I just installed java on my Ec2 instance and run above command – Harshit kyal May 02 '20 at 12:31
  • @RyanGuamos Its not working. – Harshit kyal May 02 '20 at 14:59

1 Answers1

0

You should use nohup to deploy jar file. It will run even though you close terminal E.g:- nohup java -jar javaservice.jar > nohup.log &