0

So I have a rest server, in Java. Sometimes the server can crash because of problems or errors in Java, memory outage and more. My problem is that I want this server to always run even after it crashes. Whenever the machine is running, I need the server to run. I know about cron jobs but I am thinking of many scenarios that this would fail. Are there better practices?

1 Answers1

0

Ideally You should handle all the error scenarios . Memory management has to be done by the programmer.

In case you want to start your service whenever machine is started, You can put those scripts in the startup services available in each platform(Linux,Windows) . This will make sure that your service will be started automatically after every restart of machine.

To handle failures, its better to setup alarms Example: Send out an email when memory is full or automatic kickoff of scripts to clean up.

Goutham Nithyananda
  • 871
  • 2
  • 13
  • 25
  • yes you are right about memory management. But there some some inherit bugs with java I had in the past that caused memory overflow. Especially possible when the solution is running on a low memory machine. – Danny Browsku Mar 08 '17 at 09:33
  • refer the below links: http://stackoverflow.com/questions/7376537/linux-automatically-restarting-application-on-crash-daemons – Goutham Nithyananda Mar 08 '17 at 09:42
  • For windows service automatic restarts refer : http://stackoverflow.com/questions/9344235/how-to-restart-program-automatically-if-it-crashes-in-windows – Goutham Nithyananda Mar 08 '17 at 09:43