54 lines
1.9 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<project name="mp-server" default="deploy" basedir=".">
<property name="app.home" value="." />
<property name="target.home" value="${app.home}/target" />
<property name="zip.name" value="weixin-mp-server-bin.zip" />
<property name="host" value="服务器IP" />
<property name="pwd" value="服务器口令" />
<property name="main.dir" value="服务部署的主目录,如/usr/local/weixin" />
<property name="sub.dir" value="服务部署的子目录,如weixin-mp-server" />
<target name="removeZip">
<echo>
${host}:删除[${zip.name}]...
</echo>
<sshexec host="${host}" username="root" password="${pwd}" trust="true" command="cd ${main.dir};pwd;rm -rf ${main.dir}/${zip.name};" />
</target>
<target name="uploadZip" depends="removeZip">
<echo>
${host}:上传[${zip.name}]...
</echo>
<scp file="${target.home}/${zip.name}" todir="root:${pwd}@${host}:${main.dir}" trust="true" />
</target>
<target name="shutdownService" depends="uploadZip">
<echo>
${host}:停止[${sub.dir}]...
</echo>
<sshexec host="${host}" username="root" password="${pwd}" trust="true" command="cd ${main.dir}/${sub.dir};pwd;sh startup.sh stop;rm -rf ${main.dir}/${sub.dir};" />
</target>
<target name="unzipProject" depends="shutdownService">
<echo>
${host}:解压${zip.name}...
</echo>
<sshexec host="${host}" username="root" password="${pwd}" trust="true" command="cd ${main.dir};pwd;unzip ${zip.name};" />
</target>
<target name="startupService" depends="unzipProject">
<echo>
${host}:启动服务...
</echo>
<sshexec host="${host}" username="root" password="${pwd}" trust="true" command="cd ${main.dir}/${sub.dir};pwd;sh startup.sh start;" />
</target>
<target name="build" depends="startupService">
<echo>
target.home = ${target.home}
file.zip = ${target.home}/${zip.name}
</echo>
</target>
<target name="deploy" depends="build">
</target>
</project>