<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<!-- 集成打包 config lib sh脚本 -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptor>src/main/assembly/assembly.xml</descriptor>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- copy到远程服务器 -->
<plugin>
<groupId>com.github.goldin</groupId>
<artifactId>copy-maven-plugin</artifactId>
<version>0.2.5</version>
<executions>
<execution>
<id>deploy-archive</id>
<phase>integration-test</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<resources>
<resource>
<targetPath>scp://bppf_bgw:123456@192.168.87.3:/u1/bppf_bgw</targetPath>
<file>${project.build.directory}/${project.build.finalName}-assembly.tar.gz</file>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<!-- 启动脚本 -->
<plugin>
<groupId>com.github.goldin</groupId>
<artifactId>sshexec-maven-plugin</artifactId>
<version>0.2.5</version>
<executions>
<execution>
<id>unpack-archive</id>
<phase>integration-test</phase>
<goals>
<goal>sshexec</goal>
</goals>
<configuration>
<location>scp://bppf_bgw:123456@192.168.87.3:/u1/bppf_bgw</location>
<commands>
<!-- 不加会找不到java命令 -->
<command>export PATH=$PATH:/opt/jdk1.6.0_32/bin</command>
<!-- 不加程序启动会乱码 -->
<command>export LANG=zh_CN.GBK</command>
<command>${project.build.finalName}/shutdown.sh</command>
<command>rm -rf ${project.build.finalName}</command>
<command>tar -zxf ${project.build.finalName}-assembly.tar.gz</command>
<command>cd ${project.build.finalName}</command>
<command>./startup.sh</command>
</commands>
</configuration>
</execution>
</executions>
</plugin>
<!-- 远程部署web项目到tomcat -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<url>http://192.168.87.3:8920/manager</url>
<server>tomcatServer</server>
<path>/${project.build.finalName}</path>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
assembly.xml
<assembly>
<id>assembly</id>
<formats>
<format>tar.gz</format>
</formats>
<includeBaseDirectory>true</includeBaseDirectory>
<fileSets>
<!-- 启动脚本 -->
<fileSet>
<directory>src/main/assembly/bin
</directory>
<outputDirectory>./</outputDirectory>
<fileMode>0755</fileMode>
</fileSet>
<!-- 配置文件 -->
<fileSet>
<directory>/config</directory>
<outputDirectory>config</outputDirectory>
<fileMode>0644</fileMode>
</fileSet>
</fileSets>
<!-- 依赖jar包 -->
<dependencySets>
<dependencySet>
<outputDirectory>lib</outputDirectory>
</dependencySet>
</dependencySets>
</assembly>
listen.sh
#!/bin/bash
#Author:huangtao
#Date:2014-03-04
dirPath=`pwd`
export CLASSPATH=$CLASSPATH:${dirPath}/lib/*
monitor_params="-Dcom.sun.management.jmxremote.port=7779 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=192.168.87.3"
java -DAppName=SAG-SERVICE-PAY-JAR -XX:PermSize=200M -Xms512M -Xmx1024M -Xss128k $monitor_params com.bestpay.sag.services.net.NetServiceStart
startup.sh
#!/bin/bash
#create by huangtao, 2012-03-04
echo ">>> SAG-SERVICE-PAY service command."
#rundir="/u1/bppf_bgw/sag-service/sag-service-pay"
port="8778"
pid=`jps -v | grep SAG-SERVICE-PAY-JAR | awk '{print $1}'`
if [ -z "$pid" ]
then
echo ">>> Booting SAG-SERVICE-PAY service..."
#echo ">>> Appending console log to ${rundir}/console.log"
echo ">>> Appending console log to ./console.log"
#nohup ${rundir}/listen.sh > ${rundir}/console.log 2>&1 &
nohup ./listen.sh >> console.log 2>&1 &
else
echo ">>> [ERROR]Service already running, aborted."
exit -1
fi
exit 0
shutdown.sh
#!/bin/bash
#create by lingyunzhi, 2012-6
echo ">>> SAG-SERVICE-JAY service command. Created by lingyunzhi [tisson]."
pid=`jps -v | grep SAG-SERVICE-PAY-JAR | awk '{print $1}'`
if [ -z "$pid" ]
then
echo ">>> [ERROR] Service is not running."
else
echo ">>> Running service pid is: $pid"
kill -9 ${pid}
fi
exit 0