0

I have a java .jar file that i launch on an AWS instance in detached mode. So when i exit the ssh session, it still runs.

The app does some network stuff, and is expected to run for days until it finishes it task.

I have made logs all over the app, made log in the end of main method. I also made a global try/catch and added logging to the catch section.

Still, after some days i enter into ssh and see that the app just stopped running. No exceptions, main method did not complete because the log in the end did not trigger. It seems that the process was just killed in the middle of working. Sometimes it works for 5 hours, sometimes for 3-4 days without stopping.

I have no idea what could be the cause of this. I expect the java process to run until it finished, or until it crashes. Am i missing something?

upd: it is an aws t2.micro, i think, the free tier one. It runs ubuntu 18.04.3 LTS

lxknvlk
  • 2,744
  • 1
  • 27
  • 32

1 Answers1

0

You need to monitor the server and application. The first thing to look at is your instance cloudwatch statistics for any CPU or memory spikes. If you find one, you know what you need to fix if you want to run your application on micro instance. For further reading

Monitoring Your Instances Using CloudWatch

Alternatively, you can collect and dump the java process statistics regularly when you are running the application. This can give insight of how heap,stack and cpu usage. Check this SO post for further details :

How do I monitor the computer's CPU, memory, and disk usage in Java?

Juned Ahsan
  • 67,789
  • 12
  • 98
  • 136