新增assembly打包脚本、ant远程部署脚本、微信服务启动脚本
This commit is contained in:
parent
4cd8f61e5c
commit
d005205627
@ -1,3 +1,4 @@
|
||||
<!-- base包合并形成weixin4j-xx-full.jar -->
|
||||
<assembly
|
||||
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
|
||||
4
pom.xml
4
pom.xml
@ -210,8 +210,8 @@
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>*.xml</include>
|
||||
<include>*.properties</include>
|
||||
<include>**/*.xml</include>
|
||||
<include>**/*.properties</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
35
script/assembly.xml
Normal file
35
script/assembly.xml
Normal file
@ -0,0 +1,35 @@
|
||||
<!-- zip可执行包 -->
|
||||
<assembly
|
||||
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
|
||||
<id>bin</id>
|
||||
<formats>
|
||||
<format>zip</format>
|
||||
</formats>
|
||||
<dependencySets>
|
||||
<dependencySet>
|
||||
<useProjectArtifact>true</useProjectArtifact>
|
||||
<outputDirectory>/lib</outputDirectory>
|
||||
</dependencySet>
|
||||
</dependencySets>
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<directory>src/main/script</directory>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
<includes>
|
||||
<include>*.sh</include>
|
||||
<include>*.bat</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
<fileSet>
|
||||
<directory>target/classes</directory>
|
||||
<includes>
|
||||
<include>*.txt</include>
|
||||
<include>*.properties</include>
|
||||
<include>*.xml</include>
|
||||
</includes>
|
||||
<outputDirectory>/conf</outputDirectory>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
</assembly>
|
||||
47
script/deploy.xml
Normal file
47
script/deploy.xml
Normal file
@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="weixin4j-server" default="deploy" basedir=".">
|
||||
<property name="app.dir" value="./target" />
|
||||
<property name="zip.name" value="zip包名称,如:weixin4j-server-bin.zip" />
|
||||
<property name="host" value="主机地址,如:192.168.1.8" />
|
||||
<property name="user.name" value="用户帐号,如:root" />
|
||||
<property name="user.pwd" value="用户密码,如:123456" />
|
||||
<property name="server.dir" value="部署服务的目录,如:/usr/local/weixin4j" />
|
||||
<property name="server.name" value="部署服务的名字,如:weixin4j-server" />
|
||||
|
||||
<target name="cleanup">
|
||||
<echo>
|
||||
${host}:删除${server.dir}/${zip.name}...
|
||||
</echo>
|
||||
<sshexec host="${host}" username="${user.name}" password="${user.pwd}" trust="true" command="rm -rf ${server.dir}/${zip.name};" />
|
||||
</target>
|
||||
|
||||
<target name="upload" depends="cleanup">
|
||||
<echo>
|
||||
${host}:上传${app.dir}/${zip.name}...
|
||||
</echo>
|
||||
<scp file="${app.dir}/${zip.name}" todir="${user.name}:${user.pwd}@${host}:${server.dir}" trust="true" />
|
||||
</target>
|
||||
|
||||
<target name="shutdown" depends="upload">
|
||||
<echo>
|
||||
${host}:停止${server.name}服务,删除${server.dir}/${server.name}...
|
||||
</echo>
|
||||
<sshexec host="${host}" username="${user.name}" password="${user.pwd}" trust="true" command="cd ${server.dir};pwd;sh ${server.name}/startup.sh stop;rm -rf ${server.dir}/${server.name};" />
|
||||
</target>
|
||||
|
||||
<target name="startup" depends="shutdown">
|
||||
<echo>
|
||||
${host}:启动${server.dir}/${server.name}...
|
||||
</echo>
|
||||
<sshexec host="${host}" username="${user.name}" password="${user.pwd}" trust="true" command="cd ${server.dir};pwd;unzip ${zip.name};sh ${server.name}/startup.sh start;" />
|
||||
</target>
|
||||
|
||||
<target name="build" depends="startup">
|
||||
<echo>
|
||||
app.dir = ${app.dir}
|
||||
file.zip = ${app.dir}/${zip.name}
|
||||
</echo>
|
||||
</target>
|
||||
<target name="deploy" depends="build">
|
||||
</target>
|
||||
</project>
|
||||
144
script/startup.sh
Normal file
144
script/startup.sh
Normal file
@ -0,0 +1,144 @@
|
||||
# Jar执行脚本
|
||||
|
||||
ulimit -n 110000
|
||||
#Jdk home
|
||||
JAVA_HOME="/usr/local/java"
|
||||
|
||||
#Executing user
|
||||
RUNNING_USER=root
|
||||
|
||||
#App home
|
||||
APP_HOME="/path/to/java/app"
|
||||
|
||||
#Main class
|
||||
APP_MAINCLASS=xx.xxx.mainClass.fullName
|
||||
|
||||
#classpath
|
||||
CLASSPATH=$APP_HOME/classes
|
||||
for i in "$APP_HOME"/lib/*.jar; do
|
||||
CLASSPATH="$CLASSPATH":"$i"
|
||||
done
|
||||
|
||||
CLASSPATH="$CLASSPATH":"$APP_HOME"/conf
|
||||
|
||||
#jvm options
|
||||
JAVA_OPTS="-Xms256m -Xmx512m -Djava.awt.headless=true -XX:MaxPermSize=128m -server -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=85 -XX:+DisableExplicitGC -Xnoclassgc -Xverify:none"
|
||||
|
||||
#psid
|
||||
psid=0
|
||||
|
||||
checkpid() {
|
||||
javaps=`$JAVA_HOME/bin/jps -l | grep $APP_MAINCLASS`
|
||||
|
||||
if [ -n "$javaps" ]; then
|
||||
psid=`echo $javaps | awk '{print $1}'`
|
||||
else
|
||||
psid=0
|
||||
fi
|
||||
}
|
||||
|
||||
###################################
|
||||
#startup
|
||||
###################################
|
||||
start() {
|
||||
checkpid
|
||||
|
||||
if [ $psid -ne 0 ]; then
|
||||
echo "================================"
|
||||
echo "warn: $APP_MAINCLASS already started! (pid=$psid)"
|
||||
echo "================================"
|
||||
else
|
||||
echo -n "Starting $APP_MAINCLASS ..."
|
||||
# JAVA_CMD="nohup $JAVA_HOME/bin/java $JAVA_OPTS -classpath $CLASSPATH $APP_MAINCLASS >/dev/null 2>&1 &"
|
||||
JAVA_CMD="$JAVA_HOME/bin/java $JAVA_OPTS -classpath $CLASSPATH $APP_MAINCLASS &"
|
||||
su - $RUNNING_USER -c "$JAVA_CMD"
|
||||
checkpid
|
||||
if [ $psid -ne 0 ]; then
|
||||
echo "(pid=$psid) [OK]"
|
||||
else
|
||||
echo "[Failed]"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
###################################
|
||||
#stop
|
||||
###################################
|
||||
stop() {
|
||||
checkpid
|
||||
|
||||
if [ $psid -ne 0 ]; then
|
||||
echo -n "Stopping $APP_MAINCLASS ...(pid=$psid) "
|
||||
su - $RUNNING_USER -c "kill -9 $psid"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "[OK]"
|
||||
else
|
||||
echo "[Failed]"
|
||||
fi
|
||||
|
||||
checkpid
|
||||
if [ $psid -ne 0 ]; then
|
||||
stop
|
||||
fi
|
||||
else
|
||||
echo "================================"
|
||||
echo "warn: $APP_MAINCLASS is not running"
|
||||
echo "================================"
|
||||
fi
|
||||
}
|
||||
|
||||
###################################
|
||||
#status
|
||||
###################################
|
||||
status() {
|
||||
checkpid
|
||||
|
||||
if [ $psid -ne 0 ]; then
|
||||
echo "$APP_MAINCLASS is running! (pid=$psid)"
|
||||
else
|
||||
echo "$APP_MAINCLASS is not running"
|
||||
fi
|
||||
}
|
||||
|
||||
###################################
|
||||
#info
|
||||
###################################
|
||||
info() {
|
||||
echo "System Information:"
|
||||
echo "****************************"
|
||||
echo `head -n 1 /etc/issue`
|
||||
echo `uname -a`
|
||||
echo
|
||||
echo "JAVA_HOME=$JAVA_HOME"
|
||||
echo `$JAVA_HOME/bin/java -version`
|
||||
echo
|
||||
echo "APP_HOME=$APP_HOME"
|
||||
echo "APP_MAINCLASS=$APP_MAINCLASS"
|
||||
echo "****************************"
|
||||
}
|
||||
|
||||
###################################
|
||||
#access only 1 argument:{start|stop|restart|status|info}
|
||||
###################################
|
||||
case "$1" in
|
||||
'start')
|
||||
start
|
||||
;;
|
||||
'stop')
|
||||
stop
|
||||
;;
|
||||
'restart')
|
||||
stop
|
||||
start
|
||||
;;
|
||||
'status')
|
||||
status
|
||||
;;
|
||||
'info')
|
||||
info
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|status|info}"
|
||||
exit 1
|
||||
esac
|
||||
exit 0
|
||||
@ -682,6 +682,10 @@
|
||||
<code>45027</code>
|
||||
<text>mpnews每天只能发送100次</text>
|
||||
</error>
|
||||
<error>
|
||||
<code>45032</code>
|
||||
<text>作者名字长度超过限制</text>
|
||||
</error>
|
||||
<error>
|
||||
<code>46001</code>
|
||||
<text>不存在媒体数据</text>
|
||||
|
||||
@ -3,7 +3,7 @@ weixin4j-server
|
||||
|
||||
[微信回调消息](http://mp.weixin.qq.com/wiki/1/6239b44c206cab9145b1d52c67e6c551.html)服务器
|
||||
----------------
|
||||
base on netty.
|
||||
based on netty.
|
||||
|
||||
功能列表
|
||||
-------
|
||||
|
||||
@ -48,7 +48,7 @@
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
<version>4.2.0.RELEASE</version>
|
||||
<scope>test</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
Loading…
x
Reference in New Issue
Block a user