Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tomcat move from Windows to Linux

 
John Farrel
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

We are in the process of moving a bunch of tomcat 7 apps from windows to linux.

We also have a java app that controls and deploys new builds to these tomcat installations.
Currently the java app runs on a windows box and uses sc to shutdown/restart the tomcat windows service.
I know tomcat has it's own web manager, but we have found it to be pretty unreliable, which is why we deploy by stopping the web server at the OS level, updating then restarting.

The question I have is;

If we run tomcat as a respawning daemon on linux, is there a way to manage it as a service in the same way I can with windows?
I would need to be able to remotely shutdown the service (update the war) and start it up again.


 
Saif Asif
Ranch Hand
Posts: 440
Eclipse IDE Hibernate Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi John,

Yes it is possible to run tomcat as a service . You just need toTake a look at this article which explains step by step on how to configure tomcat as a service on a Linux box Link . You can remotely ssh into your linux server and then start/stop the tomcat service with just a single command from anywhere. To automate the process, you can write a bash script which stops the service, updates the war for you and then restarts the tomcat service.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18276
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that if you literally mean "respawn" as in /etc/inittab, I don't recommend that. Very few system components have the necessary attributes to warrant an inittab respawn. Respawns can effectively eat your machine.

Tomcat is normally set up as a system service, which means that it's usually managed via an init script.
 
K. Gil
Ranch Hand
Posts: 75
Java Linux Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If we run tomcat as a respawning daemon on linux, is there a way to manage it as a service in the same way I can with windows?
I would need to be able to remotely shutdown the service (update the war) and start it up again.


can't see any problems here

Tomcat is normally set up as a system service, which means that it's usually managed via an init script.


at least it should be
mostly it is when you install tomcat from OS repositories, which comes with init script, but when you download tomcat package and drop it to your home dir, it doesn't.
also, in some cases you don't have root access to your server to install init scripts.

anyway, I can't see a problem with using standard tomcat's startup/shutdown scripts.

so simply upload war, ssh and execute shutdown/startup and it's done. you can even script that, easy

 
Tim Holloway
Saloon Keeper
Pie
Posts: 18276
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did make certain assumptions. Since it was a Service under Windows and similar level of operation was expected for Linux, I took it as given that admin rights would be inherent in the installation process. The closest approximation to the Windows Service Manager would be the init subsystem (historically, anyway. New stuff is beginning to move in). I write my own initscripts, since I don't install Tomcat via OS package management.

When you're running Tomcat as a ordinary (non-daemon) user, you wouldn't have that luxury as a rule, of course.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic