-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add deploy scripts of vm (#109)
- Loading branch information
Showing
15 changed files
with
556 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# 介绍 | ||
VM模式下的相关脚本. | ||
该脚本可以在 Mac m1 或 Linux 上执行, 要求机器上装有 docker. Mac m1 特别慢, 建议在 Linux 上执行, 可以通过 rsync 将代码复制到 Linux 上再构建. | ||
|
||
# 使用 | ||
```bash | ||
./scripts/vm/build.sh 1.0.0 | ||
``` | ||
|
||
构建的结果在 `/root/workspace/remote/cloudmonitor-agent/scripts/vm/holoinsight-agent_linux-amd64_1.0.0.tar.gz` | ||
|
||
之后我们把它上传到 OSS, 给用户下载安装即可. | ||
```bash | ||
./scripts/vm/upload.sh 1.0.0 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[program:agent] | ||
command=/usr/local/holoinsight/agent/bin/agent.sh | ||
process_name=%(program_name)s | ||
autostart=true | ||
# 启动后持续3秒处于RUNNING状态则认为启动成功 | ||
#startsecs=3 | ||
# 重试 | ||
startretries=3 | ||
autorestart=unexpected | ||
exitcodes=0,7 | ||
stopsignal=TERM | ||
stopwaitsecs=3 | ||
stopasgroup=true | ||
killasgroup=true | ||
redirect_stderr=true | ||
stdout_logfile=/usr/local/holoinsight/agent/logs/stdout.log | ||
stdout_logfile_maxbytes=50MB | ||
stdout_logfile_backups=10 | ||
stdout_capture_maxbytes=0 | ||
stdout_events_enabled=true | ||
#environment=KEY="val",KEY2="val2" | ||
directory=/usr/local/holoinsight/agent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bash | ||
|
||
export GOTRACEBACK=all | ||
export GODEBUG=gctrace=1,madvdontneed=1 | ||
|
||
script_dir=`dirname $0` | ||
|
||
# 如果文件存在就从它加载一些环境变量 | ||
if [ -e "$script_dir/env.sh" ]; then | ||
source $script_dir/env.sh | ||
fi | ||
|
||
exec $script_dir/agent | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
# VM 模式下的打包: 打成 tar 包, 用户下载之后解压启动即可 | ||
|
||
script_dir=`dirname $0 | xargs realpath` | ||
project_root=`realpath $script_dir/../..` | ||
|
||
version=` cat $project_root/VERSION ` | ||
|
||
echo '[build vm lite agent package]' | ||
|
||
# tar 包目录结构: | ||
# /bin | ||
# /agent agent 本体 | ||
# /data | ||
# /agent.yaml 配置文件, install 时生成 | ||
|
||
echo script dir is $script_dir | ||
echo project root is $project_root | ||
|
||
tmpdir=`mktemp -d` | ||
agent_home=$tmpdir/agent | ||
|
||
mkdir -p $agent_home/{bin,data,conf,logs} | ||
|
||
echo temp agent home $agent_home | ||
|
||
$script_dir/../build/build-using-docker.sh | ||
|
||
cp $script_dir/../../build/linux-amd64/bin/agent $agent_home/bin/agent | ||
|
||
echo | ||
echo ls -lh $agent_home | ||
ls -lh $agent_home | ||
echo | ||
|
||
build_target=$project_root/build/linux-amd64/holoinsight-agent-lite_linux-amd64_${version}.tar.gz | ||
echo "build to $build_target" | ||
cd $tmpdir/agent && tar -zcf $build_target * | ||
|
||
echo you should upload $build_target to your OSS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
# VM 模式下的打包: 打成 tar 包, 用户下载之后解压启动即可 | ||
|
||
script_dir=`dirname $0 | xargs realpath` | ||
project_root=`realpath $script_dir/../..` | ||
|
||
version=` cat $project_root/VERSION ` | ||
|
||
echo '[build vm agent package]' | ||
|
||
# tar 包目录结构: | ||
# /bin | ||
# /agent agent 本体 | ||
# /data | ||
# /agent.yaml 配置文件, install 时生成 | ||
|
||
echo script dir is $script_dir | ||
echo project root is $project_root | ||
|
||
tmpdir=`mktemp -d` | ||
agent_home=$tmpdir/agent | ||
|
||
mkdir -p $agent_home/{bin,data,conf,logs} | ||
|
||
echo temp agent home $agent_home | ||
|
||
cp $script_dir/{supervisord,supervisord.conf,ctl.sh,agent.ini,agent.sh,uninstall.sh} $agent_home/bin/ | ||
|
||
cp $script_dir/initd_holoinsight-agent.sh $agent_home/bin/initd_holoinsight-agent.sh | ||
|
||
$script_dir/../build/build-using-docker.sh | ||
|
||
cp $script_dir/../../build/linux-amd64/bin/agent $agent_home/bin/agent | ||
|
||
echo | ||
echo ls -lh $agent_home | ||
ls -lh $agent_home | ||
echo | ||
|
||
build_target=$project_root/build/linux-amd64/holoinsight-agent_linux-amd64_${version}.tar.gz | ||
echo "build to $build_target" | ||
cd $tmpdir/agent && tar -zcf $build_target * | ||
|
||
echo you should upload $build_target to your OSS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
bin_dir=`dirname $0` | ||
bin_dir=`cd $bin_dir && echo $PWD` | ||
echo bin_dir is $bin_dir | ||
|
||
SUPERVISORD_BIN=$bin_dir/supervisord | ||
SUPERVISORD_CONF=${SUPERVISORD_BIN}.conf | ||
SUPERVISORD_PID_FILE=$bin_dir/../run/supervisord.pid | ||
|
||
|
||
function start() { | ||
# TODO 防止重复启动 | ||
if [ -e "$SUPERVISORD_PID_FILE" ]; then | ||
pid=`cat $SUPERVISORD_PID_FILE` | ||
if ps -p $pid >/dev/null; then | ||
# PID 存在 | ||
return | ||
else | ||
rm -f $SUPERVISORD_PID_FILE | ||
# 文件存在但pid不存在, 启动 | ||
$SUPERVISORD_BIN -c $SUPERVISORD_CONF -d | ||
fi | ||
else | ||
# pid文件不存在, 启动 | ||
$SUPERVISORD_BIN -c $SUPERVISORD_CONF -d | ||
fi | ||
|
||
$SUPERVISORD_BIN -c $SUPERVISORD_CONF ctl start agent | ||
} | ||
|
||
function stop() { | ||
$SUPERVISORD_BIN -c $SUPERVISORD_CONF ctl stop agent | ||
|
||
out=`$SUPERVISORD_BIN -c $SUPERVISORD_CONF ctl shutdown` | ||
if [ "Shut Down" != "$out" ] && [ "Hmmm! Something gone wrong?!" != "$out" ]; then | ||
echo "stop supervisord: $out" | ||
fi | ||
|
||
if [ -e "$SUPERVISORD_PID_FILE" ]; then | ||
pid=`cat $SUPERVISORD_PID_FILE` | ||
if ps -p $pid >/dev/null 2>&1; then | ||
kill $pid || true | ||
fi | ||
rm $SUPERVISORD_PID_FILE | ||
fi | ||
|
||
pid=`ps aux | grep $SUPERVISORD_BIN | grep -v grep | awk '{ print $2 }'` | ||
if [ -n "$pid" ]; then | ||
kill $pid || true | ||
fi | ||
} | ||
|
||
function restart() { | ||
$SUPERVISORD_BIN -c $SUPERVISORD_CONF ctl restart agent | ||
} | ||
|
||
function status() { | ||
$SUPERVISORD_BIN -c $SUPERVISORD_CONF ctl status agent | ||
} | ||
|
||
case "$1" in | ||
start) | ||
start | ||
;; | ||
stop) | ||
stop | ||
;; | ||
restart) | ||
restart | ||
;; | ||
status) | ||
status | ||
;; | ||
*) | ||
echo 'usage: ctl.sh <start|stop|restart|status>' | ||
exit 1 | ||
;; | ||
esac | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
# 开机自启动时会调用这个脚本 | ||
exec /usr/local/holoinsight/agent/bin/ctl.sh "$@" |
Oops, something went wrong.