打包时添加根目录gocron

pull/21/merge
ouqiang 2017-04-25 19:54:06 +08:00
parent 638aed88cf
commit b3542c00c9
4 changed files with 16 additions and 15 deletions

View File

@ -2,7 +2,7 @@
# set -x -u # set -x -u
# 构建应用, 生成压缩包 gocron.zip或gocron.tar.gz # 构建应用, 生成压缩包 gocron.zip或gocron.tar.gz
# 使用方式 -p 指定平台(widows linux darwin) -a 指定体系架构(amd64 386), 默认amd64 # -p 指定平台(widows linux darwin) -a 指定体系架构(amd64 386), 默认amd64
# ./build.sh -p windows -a amd64 # ./build.sh -p windows -a amd64
TEMP_DIR=`date +%s`-temp-`echo $RANDOM` TEMP_DIR=`date +%s`-temp-`echo $RANDOM`
@ -18,6 +18,7 @@ EXEC_NAME=''
# 压缩包名称 # 压缩包名称
COMPRESS_FILE='' COMPRESS_FILE=''
# -p 平台 -a 架构 # -p 平台 -a 架构
while getopts "p:a:" OPT; while getopts "p:a:" OPT;
do do
@ -26,9 +27,6 @@ do
;; ;;
a) ARCH=$OPTARG a) ARCH=$OPTARG
;; ;;
\?)
echo "invalid option: -${OPTARG}"
;;
esac esac
done done
@ -66,7 +64,7 @@ else
COMPRESS_FILE=${APP_NAME}.tar.gz COMPRESS_FILE=${APP_NAME}.tar.gz
fi fi
mkdir $TEMP_DIR mkdir -p $TEMP_DIR/$APP_NAME
if [[ ! $? ]]; then if [[ ! $? ]]; then
exit 1 exit 1
fi fi
@ -78,23 +76,26 @@ echo '复制文件到临时目录'
# 复制文件到临时目录 # 复制文件到临时目录
for i in ${PACKAGE_FILENAME[*]} for i in ${PACKAGE_FILENAME[*]}
do do
cp -r $i $TEMP_DIR cp -r $i $TEMP_DIR/$APP_NAME
done done
# 删除运行时产生的文件 # 删除运行时产生的文件
rm -rf $TEMP_DIR/conf/* rm -rf $TEMP_DIR/$APP_NAME/conf/*
rm -rf $TEMP_DIR/log/* rm -rf $TEMP_DIR/$APP_NAME/log/*
echo '压缩文件' echo '压缩文件'
# 压缩文件 # 压缩文件
cd $TEMP_DIR cd $TEMP_DIR
if [[ $OS = 'windows' ]];then if [[ $OS = 'windows' ]];then
zip -r $COMPRESS_FILE * zip -rq $COMPRESS_FILE *
else else
tar cvzf $COMPRESS_FILE * tar czf $COMPRESS_FILE *
fi fi
mv $COMPRESS_FILE ../ mv $COMPRESS_FILE ../
cd .. cd ../
rm $EXEC_NAME rm $EXEC_NAME
rm -rf $TEMP_DIR rm -rf $TEMP_DIR
echo '打包完成'
echo '生成压缩文件--' $COMPRESS_FILE

View File

@ -15,7 +15,7 @@ type Host struct {
Username string `xorm:"varchar(32) notnull default '' "` // ssh 用户名 Username string `xorm:"varchar(32) notnull default '' "` // ssh 用户名
Password string `xorm:"varchar(64) notnull default ''"` // ssh 密码 Password string `xorm:"varchar(64) notnull default ''"` // ssh 密码
Port int `xorm:"notnull default 22"` // 主机端口 Port int `xorm:"notnull default 22"` // 主机端口
Remark string `xorm:"varchar(256) notnull default '' "` // 备注 Remark string `xorm:"varchar(100) notnull default '' "` // 备注
AuthType ssh.HostAuthType `xorm:"tinyint notnull default 1"` // 认证方式 1: 密码 2: 公钥 AuthType ssh.HostAuthType `xorm:"tinyint notnull default 1"` // 认证方式 1: 密码 2: 公钥
PrivateKey string `xorm:"varchar(4096) notnull default '' "` // 私钥 PrivateKey string `xorm:"varchar(4096) notnull default '' "` // 私钥
BaseModel `xorm:"-"` BaseModel `xorm:"-"`

View File

@ -24,7 +24,7 @@ type Task struct {
Timeout int `xorm:"mediumint notnull default 0"` // 任务执行超时时间(单位秒),0不限制 Timeout int `xorm:"mediumint notnull default 0"` // 任务执行超时时间(单位秒),0不限制
RetryTimes int8 `xorm:"tinyint notnull default 0"` // 重试次数 RetryTimes int8 `xorm:"tinyint notnull default 0"` // 重试次数
HostId int16 `xorm:"smallint notnull default 0"` // SSH host id HostId int16 `xorm:"smallint notnull default 0"` // SSH host id
Remark string `xorm:"varchar(256) notnull default ''"` // 备注 Remark string `xorm:"varchar(100) notnull default ''"` // 备注
Created time.Time `xorm:"datetime notnull created"` // 创建时间 Created time.Time `xorm:"datetime notnull created"` // 创建时间
Deleted time.Time `xorm:"datetime deleted"` // 删除时间 Deleted time.Time `xorm:"datetime deleted"` // 删除时间
Status Status `xorm:"tinyint notnull default 1"` // 状态 1:正常 0:停止 Status Status `xorm:"tinyint notnull default 1"` // 状态 1:正常 0:停止

View File

@ -18,11 +18,11 @@ type TaskLog struct {
Command string `xorm:"varchar(256) notnull"` // URL地址或shell命令 Command string `xorm:"varchar(256) notnull"` // URL地址或shell命令
Timeout int `xorm:"mediumint notnull default 0"` // 任务执行超时时间(单位秒),0不限制 Timeout int `xorm:"mediumint notnull default 0"` // 任务执行超时时间(单位秒),0不限制
RetryTimes int8 `xorm:"tinyint notnull default 0"` // 任务重试次数 RetryTimes int8 `xorm:"tinyint notnull default 0"` // 任务重试次数
Hostname string `xorm:"varchar(256) notnull defalut '' "` // SSH主机名逗号分隔 Hostname string `xorm:"varchar(128) notnull defalut '' "` // SSH主机名逗号分隔
StartTime time.Time `xorm:"datetime created"` // 开始执行时间 StartTime time.Time `xorm:"datetime created"` // 开始执行时间
EndTime time.Time `xorm:"datetime updated"` // 执行完成(失败)时间 EndTime time.Time `xorm:"datetime updated"` // 执行完成(失败)时间
Status Status `xorm:"tinyint notnull default 1"` // 状态 0:执行失败 1:执行中 2:执行完毕 Status Status `xorm:"tinyint notnull default 1"` // 状态 0:执行失败 1:执行中 2:执行完毕
Result string `xorm:"varchar(10000) notnull defalut '' "` // 执行结果 Result string `xorm:"varchar(4096) notnull defalut '' "` // 执行结果
TotalTime int `xorm:"-"` // 执行总时长 TotalTime int `xorm:"-"` // 执行总时长
BaseModel `xorm:"-"` BaseModel `xorm:"-"`
} }