There have been a lot of talk about automated deployments and a lot of professional tools. This article does not dare to high above the big plans, but from their own reality, the main use of SVN version of the management tools to facilitate the release and deployment. I. Reasons
As a small and medium-sized team, publishing and deployment is common, and easy to problem, we generally use the following methods are as follows: Directly replace the war package to replace the corresponding JAR package
The former is slow in times of frequent deployment (because the war package is large, at least dozens of M, it takes a few minutes at a time), the second is to find the updated jar package, and then find the appropriate location on the production environment, and then replace one by one, the procedures cumbersome and error prone. And the same problem is that when a bug occurs, it is not possible to confirm which version the production environment is deploying. Two. Solutions
To solve this problem, I use the SVN version management tool, simply put all the files that need to be deployed on the SVN server, and use SVN to update the current version on the production environment when it needs to be republished.
To do this, I wrote 3 scripts: compile_produce.sh compiling the production version check_produce.sh the first deployment on the production environment update_produce.sh the update deployment on the production environment
The scripts were as follows:
1. compile_produce.sh
#!/bin/bash-e
CD path
svn update--username=deploy
mvn clean install-p produce
echo "[Produce Environment]-------------------------------------------"
echo" [Produce environment] compile completed "
RM -RF release
mkdir release
cp-r target/app/* release/
CD release
echo "[Produce environment] copy Completed "
SVN add *--force
svn commit-m" Produce environment release "--username=deploy
echo" [Produce Environment] Commit completed "
echo" [Produce environment]-------------------------------------------"
2. check_produce.sh
#!/bin/bash-e
CD path
svn checkout URL--username=deploy--password=deploy
3. update_produce.sh
#!/bin/bash
CD path
svn revert-r.
SVN update--username=deploy--password=deploy
echo "[Produce environment]------------------------------------- ------"
echo" [Produce environment] update completed "
pid= ' ps-ef | grep tomcat7 | grep-v ' grep ' | awk ' {print $ } '
kill-9 $pid
echo ' [Produce environment] kill process completed '
tomcat/tomcat7/bin/startup.sh
echo [Produce environment] start Tomcat "
echo" [Produce environment]------------------------------------------ -"
date= ' DATE ' +%y-%m-%d '
tail-f/fqgj/tomcat/tomcat7/logs/catalina.${date}.out
In the final step, you can see the log output of Tomcat to show that the publication was successful.
With this approach, the final deployment can be done only by compiling and updating two scripts. Do the release of the order, time is also very fast, generally only need more than 10 seconds. And it can pinpoint the version of the production environment and avoid some problems caused by the unclear version.