Roman Proshin
Roman Proshin

Reputation: 909

Restart a Tomcat on Jelastic automatically

I have a Tomcat 7 instance in Dogado Jelastic cloud (Jelastic platform version is 2.5.2). As well I have a Bamboo, which deploys everynight two applications on this Tomcat 7 instance. Due to some problems in applications I have memory leaks, which break the apps after some time. So I want to restart the server periodically to fix this problem (I know it's not good fix, but that's enough for now). I found a few ways to restart the Tomcat 7 automatically:

  1. Using Jelastic REST API - it requires to do two requests: authentication and action).
  2. Using cron tasks (which are provided by jelastic admin panel) - it seems that Jelastic doesn't see a newly started Tomcat's instance.

So I have two questions:

  1. Are there any ways to simplify these two methods (for example, one-call API request, or correct way to restart Tomcat using cron task)?
  2. Are there any other ways to restart Tomcat automatically?

Thanks!

Upvotes: 0

Views: 687

Answers (2)

Ruslan
Ruslan

Reputation: 395

Just add this command to the cron/tomcat via dashboard config panel

0 * * * * /opt/tomcat/bin/shutdown.sh; /opt/tomcat/bin/startup.sh

It works fine for tomcat7.

Upvotes: 2

Damien - Layershift
Damien - Layershift

Reputation: 1528

For the cron option, you need to do this from the root user (that's why when you do it from your jelastic user via the dashboard it does not work in the expected way).

However, Dogado should be able to configure this cron for you without any issues. I recommend this as your simplest solution in this case.

The difficulty with the API restart option is you will probably need to execute that from somewhere else (e.g. not a script invoked via cron inside your environment). Unless you already have a suitable system (e.g. another environment, or a server elsewhere) that probably isn't a viable approach.

Personally I also dislike that the API requires your Jelastic username/password, so grants full access to all of your environments - even if you only want it to have permission to just one. You can potentially work around that limitation by creating a collaborator, sharing the environment with them, and treating that user as your "API user".

Upvotes: 0

Related Questions