Registering Tomcat to Window service service
1. Software and Environment
- Environment: JDK1.8
- App Service: Tomcat9.0 (non-installation version)
- Operating system: Windows 2012
2. Set up Tomcat for system service
Win+r Open the Run window, enter CMD to open the DOS window, and use the CD command to switch the location to the bin file under the Tomcat path.
cd C:\apache-tomcat-9.0.8\bin。输入service命令可以查看service.bat文件的使用说明,C:\apache-tomcat-9.0.8\bin>service.batUsage: service.bat install/remove [service_name] [/user username]C:\apache-tomcat-9.0.8\bin>
Enter Service.bat install service_name can be installed services, SERVICE_NAME is to service the name, you can name, I have the name of the Tomcatservice.
C:\apache-tomcat-9.0.8\bin>service install TomcatServiceInstalling the service ‘TomcatService‘ ...Using CATALINA_HOME: "C:\apache-tomcat-9.0.8"Using CATALINA_BASE: "C:\apache-tomcat-9.0.8"Using JAVA_HOME: "C:\Program Files\Java\jdk1.8.0_171"Using JRE_HOME: "C:\Program Files\Java\jdk1.8.0_171\jre"Using JVM: "C:\Program Files\Java\jdk1.8.0_171\jre\bin\server\jvm.dll"The service ‘TomcatService‘ has been installed.C:\apache-tomcat-9.0.8\bin>
3, modify the starting mode
Win+r Open the Run window, enter the control command to open the dashboard, locate the administration tool, open the service, and you will see a newly registered service called Apache Tomcat 9.0 tomcatservice. Right-click the property to change the startup type to Automatic.
4. Setting up Dependent services
Sometimes we need to start the database service before we start the Tomcat service. That is, the start-up database service starts after startup to automatically start the Tomcat service, which is the ability to set up Tomcat service and database service dependencies on.
Suppose the computer now has a registered database service, named Mysqlservice, now to set Tomcatservice and Mysqlservice dependent on the use of SC config Tomcatservice depend= Mysqlservice command to execute (note that there is a space between depend= and Mysqlservice). After you set it up, you can view it in the properties of the service--dependencies.
5. Delete Registered Services
Remove the registered service, similar to the Install command, using Remove. Open the DOS window and enter service remove Tomcat99 to delete the services.
C:\apache-tomcat-9.0.8\bin>service.bat remove tomcat99Removing the service ‘tomcat99‘ ...Using CATALINA_BASE: "C:\apache-tomcat-9.0.8"The service ‘tomcat99‘ has been removedC:\apache-tomcat-9.0.8\bin>
Registering Tomcat to Window service service