|
How to Run Tomcat 7 as a Windows Service with AlwaysUp
|
Ensure that Tomcat starts after a reboot and runs 24/7!
Tomcat is a world class, open source Java Servlet container developed by the Apache Software Foundation.
To set up Tomcat with AlwaysUp 6.0 and later:
-
Download and install AlwaysUp, if necessary.
-
Download and install the Java runtime environment (JRE), if necessary.
Be sure to set the JAVA_HOME environment variable so that Tomcat will be able to find Java when it is run!
-
Download and install Tomcat 7, if necessary.
Please make a note of where you installed it as this will be used in a later step. We have used C:\Tomcat.
-
Tomcat includes a batch file named startup.bat that will start the server but unfortunately the file will not work properly with AlwaysUp.
We must make a copy, change one line, and use the new file in AlwaysUp.
To make the changes:
- Open Windows Explorer to the directory where you installed Tomcat.
- Navigate to the bin subdirectory.
- Find the startup.bat file, make a copy of it in the same directory and rename it to startup-from-alwaysup.bat.
- Open the new file in Notepad.
- Change the line:
call "%EXECUTABLE%" start %CMD_LINE_ARGS%
to
call "%EXECUTABLE%" run %CMD_LINE_ARGS%
(The "run" argument prevents the batch file from starting java in a
separate window, which would prevent AlwaysUp from keeping track of it
properly.
Please see the catalina.bat file for details.)
-
Start AlwaysUp.
-
Select Application > Add to open the Add Application window:
-
On the General tab:
-
In the Application field, enter the full path to the batch file that we created in step 3, startup-from-alwaysup.bat.
-
In the Name field, enter the name that you will call the application in AlwaysUp.
We suggest Tomcat but you can specify almost anything you like.
-
By default, Tomcat will show a command window when it is run by AlwaysUp. This can be useful for
debugging purposes, but if you wish to avoid seeing it, click over to the Logon tab and check the When a user logs on, don't show the application's windows... box.
-
Click over to the Startup tab and check the Ensure that the Windows Networking components have started box.
This informs AlwaysUp that Tomcat needs the TCP/IP networking stack to operate.
-
Click over to the Extras tab. Check the Use this special command to stop the application box and enter the full path to the shutdown.bat file in the
Tomcat bin directory. This will ensure that Tomcat is shut down gracefully when it is stopped by AlwaysUp.
-
Click the Save >> button. In a couple of seconds, an application called Tomcat will show up in the AlwaysUp window.
It is not yet running though.
-
To start Tomcat, choose Application > Start "Tomcat".
-
That's it! Next time your computer boots, Tomcat will start up immediately, before anyone logs on.
We encourage you to edit Tomcat in AlwaysUp and check out the many other settings that may be appropriate for your environment.
Article Source