Because Linux and Java are like open source. So, now in the server basically use the Deploy Linux platform as server. Then deploy the project. In the process of developing the project. The vast majority of programmers still use the most classic Windows operating system, although Linux also has a system desktop, for the people, or not very accustomed. Linux platforms. So in the frequency of use that is quite a little!
In the development, the development environment in the compilation of the use of a series of passed, not to say that the function is OK. As the environment changes, the problems that arise may be self-considered. So programmers know that the real environment is the most reliable, and sometimes problems arise. It takes a lot of talent to reproduce in a real environment, even for a long time. So it's quite necessary to do a lot of testing in the real world!
In terms of how to improve the deployment environment:
A shell script is used here to introduce the shell script: The shell Script,shell script is similar to the batch processing under Windows/dos, that is, a program file that is pre-placed in a file with various commands to facilitate a one-time run. It is mainly convenient for administrators to set up or manage. However, it is more powerful than batch processing under Windows. It is more efficient than editing programs with other programming programs, after all, it uses the commands under Linux/unix.
In other words, shell script is a program that uses the shell's function abbreviation, which uses a plain text file. Write some shell syntax and instructions in the inside. Then we use regular notation, pipeline commands, and data flow redirection to achieve the purpose we want to handle.
More specifically, shell script wants to get up early in the DOS age. bat, the simplest function is to write a lot of instructions together, so that the user is very easy to do one operation to run multiple commands, and shell script provides arrays, loops, conditions, as well as logical inference and other important functions. Allows the user to tap the code directly from the shell without having to use the syntax written by traditional programs like the C programming language.
The shell is simply introduced here. Now directly paste the contents of the shell script (tom.sh)
#!/bin/bashservice Tomcat stopsleep 3#kill javakillall java#remove pidrm-rf/var/run/tomcat.pidrm-rf/nac/web/tomcat/ webapps/hupunac*/nac/web/tomcat/webapps/rootrm-rf/nac/web/tomcat/work/* #clear log>/var/log/tomcat/ Catalina.out#rzcd/nac/web/tomcat/webappsrz#start tomcatsleep 3service Tomcat Start#echo "Please wait for 80s ..." Sleep 80netstat-an|grep::: 6002 >/dev/nullif [$?! = 0];then service tomcat stop killall java rm-rf/va R/run/tomcat.pid Service Tomcat Startelse echo "Tomcat start ok!" Fi
Here's
The service Tomcat Stop command should be very clear, which is to first stop the Tomcat services. Of course, at this point, the Tomcat service itself is not turned on, but does not affect the entire script running
Sleep 3 refers to sleeping 3s (seconds). Commonly known as waiting 3 seconds
Killall Java forced kill Java program
RM-RF Force Delete, use this command, mainly to remove files under the server that must be deleted
> This command is to empty the file meaning, in my main is to empty the log file
CD refers to the Access folder
RZ refers to the file import, which is the general view in Windows. Then upload
Service Tomcat start this time, after the successful war upload of our project, start the service, and then wait for the service to open
Here is an optimization, because the use of 6002port in our program, so the assumption that the service opened port is not up, that is, the listen state. Netstat-an This command is used to view all the port information in the current system, the 6002port in these ports is the data we need, so we can use Netstat-an|grep::: 6002来 filter!
If it doesn't, it means that there was a problem with the Tomcat service opening process, and then we went through the process again, which is just one less step to upload the war package.
All right. The script presentation is complete. That's when we're able to run. The/nac/script/tom.sh,ok project is easy to deploy!
This is the time to ask the personnel. Such a long path, so hard to find, very troublesome! It is not possible to optimize it, of course. Must be able to optimize. Here are two ways to optimize:
1. Add alias webupdate= ' under the. bashrc file under root. /nac/script/tom.sh '
2, add alias webupdate= ' in/etc/profile. /nac/script/tom.sh '
Both methods are introduced, two optimization methods are OK, the latter is better, more convenient, because the latter is configured in the system environment variables, and the former is configured in the root user environment variables, has been only the root can use. In the latter case, all users are able to use the command. This makes it easy to change the war package deployment with the Webupdate command
Perhaps this time someone will ask, with the command how to say that does not exist! Of course, the device does not restart. The configuration of these resources are again loaded, certainly not used, restart the device is OK, restart the device is too laborious, we can use a source a bit better, so you can directly use the command just configured, remember that source is the source of the file just changed!
In the end we can be very easy and very convenient very quickly can put our project once again deployed!
Attach the most frequently used Linux command set to you: http://blog.csdn.net/luo201227/article/details/23295435
Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.
Linux deployment environment in high-iron projects