阿里云流水线云效简单使用教程

云效地址

https://flow.aliyun.com/setting

 

 

 

 

 

 进入我的流水线

https://flow.aliyun.com/my?page=1

 

 

 

 

 

 部署脚本

mkdir -p /home/admin/application/
tar zxvf /home/admin/app/package.tgz -C /home/admin/app/
sh /home/admin/app/ip.sh start

 你的项目需要ip.sh文件

我的项目是用的springboot开发的

shell脚本参考

#!/bin/bash
# 定义常用路径和变量
VIPDAY_HOME="/home/server"
VIPDAY_HOME1="/home/server/application/target"
PROJECT_DIRECTORY="/target"
SERVER_PORT="3021"
new_jar_file=server.jar

# 动态生成日志文件名
LOG_FILE_NAME="$VIPDAY_HOME1/app_log_$(date +%Y-%m-%d_%H-%M-%S).log"

# Function to get the total memory in GB
get_total_memory() {
    mem=$(free -g | awk '/^Mem:/{print $2}')
    echo "$mem"
}
calculate_heap_size() {
    total_mem_gb=$(get_total_memory)
    if [ "$total_mem_gb" -lt 2 ]; then
        heap_size="512M"
    elif [ "$total_mem_gb" -lt 4 ]; then
        heap_size="1G"
    elif [ "$total_mem_gb" -lt 8 ]; then
        heap_size="2G"
    elif [ "$total_mem_gb" -lt 16 ]; then
        heap_size="4G"
    else
        heap_size="8G"
    fi
    echo "$heap_size"
}
# 杀死已经运行的进程
pkill -f "$VIPDAY_HOME/.*\.jar.*--server.port=$SERVER_PORT"

cd "$VIPDAY_HOME1"

#mv /home/server/application/target/$new_jar_file $VIPDAY_HOME/$new_jar_file

# 计算 JVM 堆大小
heap_size=$(calculate_heap_size)

# 启动项目,输出日志到动态文件名
nohup java -jar -Xmx"$heap_size" -Xms"$heap_size" "$VIPDAY_HOME1/$new_jar_file" --server.port=$SERVER_PORT >"$LOG_FILE_NAME" 2>&1 &

echo "应用启动完成,日志文件:$LOG_FILE_NAME"

  

 

 

 

 

 

 项目中的脚本需要对应的修改

#!/bin/bash
# 定义常用路径和变量
VIPDAY_HOME="/home/server"
VIPDAY_HOME1="/home/server/application/target"
VIPDAY_HOME2="/home/admin/application/target"
PROJECT_DIRECTORY="/target"
SERVER_PORT="3021"
new_jar_file=server.jar

# 动态生成日志文件名
LOG_FILE_NAME="$VIPDAY_HOME2/app_log_$(date +%Y-%m-%d_%H-%M-%S).log"

# Function to get the total memory in GB
get_total_memory() {
    mem=$(free -g | awk '/^Mem:/{print $2}')
    echo "$mem"
}
calculate_heap_size() {
    total_mem_gb=$(get_total_memory)
    if [ "$total_mem_gb" -lt 2 ]; then
        heap_size="512M"
    elif [ "$total_mem_gb" -lt 4 ]; then
        heap_size="1G"
    elif [ "$total_mem_gb" -lt 8 ]; then
        heap_size="2G"
    elif [ "$total_mem_gb" -lt 16 ]; then
        heap_size="4G"
    else
        heap_size="8G"
    fi
    echo "$heap_size"
}
# 杀死已经运行的进程
pkill -f "$VIPDAY_HOME/.*\.jar.*--server.port=$SERVER_PORT"

cd "$VIPDAY_HOME2"

#mv /home/server/application/target/$new_jar_file $VIPDAY_HOME/$new_jar_file

# 计算 JVM 堆大小
heap_size=$(calculate_heap_size)

# 启动项目,输出日志到动态文件名
nohup java -jar -Xmx"$heap_size" -Xms"$heap_size" "$VIPDAY_HOME2/$new_jar_file" --server.port=$SERVER_PORT >"$LOG_FILE_NAME" 2>&1 &

echo "应用启动完成,日志文件:$LOG_FILE_NAME"

  

 

 通过排查是流水线源错了,拉错分支了

 

 

 

posted @ 2024-08-08 15:32  不忘初心2021  阅读(8)  评论(0编辑  收藏  举报