diff --git a/jenkins/流水线配置/go_中转服务/s5_go_lessie_sourcing_api copy.conf b/jenkins/流水线配置/go_中转服务/s5_go_lessie_sourcing_api copy.conf new file mode 100644 index 0000000..b295ca6 --- /dev/null +++ b/jenkins/流水线配置/go_中转服务/s5_go_lessie_sourcing_api copy.conf @@ -0,0 +1,98 @@ +pipeline { + agent any + tools{ + go 'go1.24.0' + } + environment { + REMOTE_HOST_A = "49.51.33.153" + REMOTE_PROJECT_PATH_A = "/data/webapps/go_lessie_sourcing_api_s5" + PORT_A = "8100" + CONNECTION_TIMEOUT = "300" // 等待连接关闭的超时时间 + CHECK_PORT_SCRIPT = "/data/sh/check_port.sh" // 检查服务所运行的端口是否起起来 + SEND_STOP_GOAPP_SCRIPT = "/data/sh/send_stop_goapp_s5.sh" // 发送GO的优雅停止信号 + WAIT_CONNECTIONS_SCRIPT = "/data/sh/wait_for_connections.sh" // 监测实例A是否有连接 + } + + stages { + stage('Checkout代码') { + steps { + echo "阶段一" + git branch: "${params.Code_branch}", credentialsId: 'fly_gitlab_auth', url: 'http://172.24.16.20/go/lessie-sourcing-api.git' + } + } + stage('依赖&构建') { + steps { + echo "阶段二" + sh """ + cd ${WORKSPACE}/ + export GOVCS="git.deeplink.media:git,*:git" + echo "拉依赖" + go mod tidy -v -x + echo "构建二进制文件" + make build-linux + cp ./build/lessie-sourcing-api ./build/lessie-sourcing-api-s5 + chmod +x ./build/lessie-sourcing-api-s5 + """ + } + } + stage('A同步') { + steps { + echo "阶段三" + sh """ + echo "进入jenkins工作目录:${WORKSPACE}" + cd ${WORKSPACE}/ + echo "同步二进制产物" + rsync -avzuP ./build/lessie-sourcing-api-s5 ./configs/application_s5.yaml ${REMOTE_HOST_A}:${REMOTE_PROJECT_PATH_A}/ + """ + } + } + stage('A下线') { + steps { + echo "阶段三" + sh """ + ssh ${REMOTE_HOST_A} ' + echo "向实例A发送优雅关闭信号" + sh ${SEND_STOP_GOAPP_SCRIPT} + echo "监测实例A是否有连接" + sh ${WAIT_CONNECTIONS_SCRIPT} ${PORT_A} ${CONNECTION_TIMEOUT} + ' + """ + } + } + stage('A启动') { + steps { + echo "阶段四" + sh """ + ssh ${REMOTE_HOST_A} ' + cd ${REMOTE_PROJECT_PATH_A} + chmod +x ./lessie-sourcing-api-s5 + nohup env ENV=s5 ./lessie-sourcing-api-s5 --port 8100 > ./go.log 2>&1 & + ' + """ + } + } + stage('探测A服务 ') { + steps { + echo "阶段五" + sh "sleep 10" + sh """ + ssh ${REMOTE_HOST_A} ' + echo "查看实例A的启动日志" + head -n 5 ${REMOTE_PROJECT_PATH_A}/go.log || true + sh ${CHECK_PORT_SCRIPT} 8100 60 + sleep 5 + ps aux|grep lessie-sourcing-api-s5 + ' + """ + } + } + } + post { + success { + echo '✅ 部署成功!' + } + failure { + echo '❌ 部署失败,请检查日志!' + } + } +} \ No newline at end of file diff --git a/jenkins/流水线配置/go_中转服务/s5_go_lessie_sourcing_api.conf b/jenkins/流水线配置/go_中转服务/s5_go_lessie_sourcing_api.conf new file mode 100644 index 0000000..b295ca6 --- /dev/null +++ b/jenkins/流水线配置/go_中转服务/s5_go_lessie_sourcing_api.conf @@ -0,0 +1,98 @@ +pipeline { + agent any + tools{ + go 'go1.24.0' + } + environment { + REMOTE_HOST_A = "49.51.33.153" + REMOTE_PROJECT_PATH_A = "/data/webapps/go_lessie_sourcing_api_s5" + PORT_A = "8100" + CONNECTION_TIMEOUT = "300" // 等待连接关闭的超时时间 + CHECK_PORT_SCRIPT = "/data/sh/check_port.sh" // 检查服务所运行的端口是否起起来 + SEND_STOP_GOAPP_SCRIPT = "/data/sh/send_stop_goapp_s5.sh" // 发送GO的优雅停止信号 + WAIT_CONNECTIONS_SCRIPT = "/data/sh/wait_for_connections.sh" // 监测实例A是否有连接 + } + + stages { + stage('Checkout代码') { + steps { + echo "阶段一" + git branch: "${params.Code_branch}", credentialsId: 'fly_gitlab_auth', url: 'http://172.24.16.20/go/lessie-sourcing-api.git' + } + } + stage('依赖&构建') { + steps { + echo "阶段二" + sh """ + cd ${WORKSPACE}/ + export GOVCS="git.deeplink.media:git,*:git" + echo "拉依赖" + go mod tidy -v -x + echo "构建二进制文件" + make build-linux + cp ./build/lessie-sourcing-api ./build/lessie-sourcing-api-s5 + chmod +x ./build/lessie-sourcing-api-s5 + """ + } + } + stage('A同步') { + steps { + echo "阶段三" + sh """ + echo "进入jenkins工作目录:${WORKSPACE}" + cd ${WORKSPACE}/ + echo "同步二进制产物" + rsync -avzuP ./build/lessie-sourcing-api-s5 ./configs/application_s5.yaml ${REMOTE_HOST_A}:${REMOTE_PROJECT_PATH_A}/ + """ + } + } + stage('A下线') { + steps { + echo "阶段三" + sh """ + ssh ${REMOTE_HOST_A} ' + echo "向实例A发送优雅关闭信号" + sh ${SEND_STOP_GOAPP_SCRIPT} + echo "监测实例A是否有连接" + sh ${WAIT_CONNECTIONS_SCRIPT} ${PORT_A} ${CONNECTION_TIMEOUT} + ' + """ + } + } + stage('A启动') { + steps { + echo "阶段四" + sh """ + ssh ${REMOTE_HOST_A} ' + cd ${REMOTE_PROJECT_PATH_A} + chmod +x ./lessie-sourcing-api-s5 + nohup env ENV=s5 ./lessie-sourcing-api-s5 --port 8100 > ./go.log 2>&1 & + ' + """ + } + } + stage('探测A服务 ') { + steps { + echo "阶段五" + sh "sleep 10" + sh """ + ssh ${REMOTE_HOST_A} ' + echo "查看实例A的启动日志" + head -n 5 ${REMOTE_PROJECT_PATH_A}/go.log || true + sh ${CHECK_PORT_SCRIPT} 8100 60 + sleep 5 + ps aux|grep lessie-sourcing-api-s5 + ' + """ + } + } + } + post { + success { + echo '✅ 部署成功!' + } + failure { + echo '❌ 部署失败,请检查日志!' + } + } +} \ No newline at end of file diff --git a/jenkins/流水线配置/go_中转服务/s6_go_lessie_sourcing_api.conf b/jenkins/流水线配置/go_中转服务/s6_go_lessie_sourcing_api.conf new file mode 100644 index 0000000..4c5e70e --- /dev/null +++ b/jenkins/流水线配置/go_中转服务/s6_go_lessie_sourcing_api.conf @@ -0,0 +1,98 @@ +pipeline { + agent any + tools{ + go 'go1.24.0' + } + environment { + REMOTE_HOST_A = "49.51.33.153" + REMOTE_PROJECT_PATH_A = "/data/webapps/go_lessie_sourcing_api_s6" + PORT_A = "8101" + CONNECTION_TIMEOUT = "300" // 等待连接关闭的超时时间 + CHECK_PORT_SCRIPT = "/data/sh/check_port.sh" // 检查服务所运行的端口是否起起来 + SEND_STOP_GOAPP_SCRIPT = "/data/sh/send_stop_goapp_s6.sh" // 发送GO的优雅停止信号 + WAIT_CONNECTIONS_SCRIPT = "/data/sh/wait_for_connections.sh" // 监测实例A是否有连接 + } + + stages { + stage('Checkout代码') { + steps { + echo "阶段一" + git branch: "${params.Code_branch}", credentialsId: 'fly_gitlab_auth', url: 'http://172.24.16.20/go/lessie-sourcing-api.git' + } + } + stage('依赖&构建') { + steps { + echo "阶段二" + sh """ + cd ${WORKSPACE}/ + export GOVCS="git.deeplink.media:git,*:git" + echo "拉依赖" + go mod tidy -v -x + echo "构建二进制文件" + make build-linux + cp ./build/lessie-sourcing-api ./build/lessie-sourcing-api-s6 + chmod +x ./build/lessie-sourcing-api-s6 + """ + } + } + stage('A同步') { + steps { + echo "阶段三" + sh """ + echo "进入jenkins工作目录:${WORKSPACE}" + cd ${WORKSPACE}/ + echo "同步二进制产物" + rsync -avzuP ./build/lessie-sourcing-api-s6 ./configs/application_s6.yaml ${REMOTE_HOST_A}:${REMOTE_PROJECT_PATH_A}/ + """ + } + } + stage('A下线') { + steps { + echo "阶段三" + sh """ + ssh ${REMOTE_HOST_A} ' + echo "向实例A发送优雅关闭信号" + sh ${SEND_STOP_GOAPP_SCRIPT} + echo "监测实例A是否有连接" + sh ${WAIT_CONNECTIONS_SCRIPT} ${PORT_A} ${CONNECTION_TIMEOUT} + ' + """ + } + } + stage('A启动') { + steps { + echo "阶段四" + sh """ + ssh ${REMOTE_HOST_A} ' + cd ${REMOTE_PROJECT_PATH_A} + chmod +x ./lessie-sourcing-api-s6 + nohup env ENV=s6 ./lessie-sourcing-api-s6 --port 8101 > ./go.log 2>&1 & + ' + """ + } + } + stage('探测A服务 ') { + steps { + echo "阶段五" + sh "sleep 10" + sh """ + ssh ${REMOTE_HOST_A} ' + echo "查看实例A的启动日志" + head -n 5 ${REMOTE_PROJECT_PATH_A}/go.log || true + sh ${CHECK_PORT_SCRIPT} 8101 60 + sleep 5 + ps aux|grep lessie-sourcing-api-s6 + ' + """ + } + } + } + post { + success { + echo '✅ 部署成功!' + } + failure { + echo '❌ 部署失败,请检查日志!' + } + } +} \ No newline at end of file diff --git a/jenkins/流水线配置/s4.jennie.im.conf b/jenkins/流水线配置/s4.jennie.im.conf index b517413..cb621af 100644 --- a/jenkins/流水线配置/s4.jennie.im.conf +++ b/jenkins/流水线配置/s4.jennie.im.conf @@ -113,7 +113,7 @@ node { source ${cfg.venvDir}/bin/activate TIMESTAMP=\$(date +"%Y%m%d_%H%M%S") LOGFILE="${cfg.projectPath}/logs/lessie_sourcing_agents_\${TIMESTAMP}.log" - nohup env APP_ENV=s1 gunicorn -w ${cfg.gunicornWorkers} -k uvicorn.workers.UvicornWorker \ + nohup env APP_ENV=s4 gunicorn -w ${cfg.gunicornWorkers} -k uvicorn.workers.UvicornWorker \ -b 0.0.0.0:${cfg.port} --timeout 300 dialogue.app:app \ --max-requests 200 --max-requests-jitter 50 \ > "\$LOGFILE" 2>&1 & diff --git a/jenkins/流水线配置/s5.jennie.im.conf b/jenkins/流水线配置/s5.jennie.im.conf new file mode 100644 index 0000000..c51c527 --- /dev/null +++ b/jenkins/流水线配置/s5.jennie.im.conf @@ -0,0 +1,123 @@ +node { + properties([ + parameters([ + // 分支选择参数 + gitParameter( + branchFilter: 'origin/(.*)', + defaultValue: 'master', + description: 's4环境,默认master分支', + name: 'Code_branch', + quickFilterEnabled: true, + selectedValue: 'DEFAULT', + sortMode: 'NONE', + type: 'PT_BRANCH', + size: 1 + ), + // 部署实例选择 + choice( + name: 'DEPLOY_TARGETS', + choices: ['A'], + description: '选择需要部署的实例' + ), + // 部署顺序 + string( + name: 'DEPLOY_ORDER', + defaultValue: 'A', + description: '指定部署顺序' + ) + ]) + ]) + + // 环境配置(集中管理实例参数) + def config = [ + A: [ + remoteHost: "49.51.33.153", + projectPath: "/data/webapps/lessie_sourcing_agents_s5", + venvDir: "/data/webapps/lessie_sourcing_agents_s5/.venv", + port: "8000", + killScript: "/data/sh/kill_lessie_sourcing_agents.sh", + checkScript: "/data/sh/check_lessie_agents_8000.sh", + gunicornWorkers: 4 + ], + ] + + + stage('拉代码') { + checkout scm: [ + $class: 'GitSCM', + branches: [[name: params.Code_branch]], + userRemoteConfigs: [[ + url: 'http://172.24.16.20/python/lessie-sourcing-agents.git', + credentialsId: 'fly_gitlab_auth' + ]] + ] + } + + stage('验证参数') { + def selectedTargets = params.DEPLOY_TARGETS.split(',').toList() + def orderChars = params.DEPLOY_ORDER.split('').toList() + + if (orderChars.isEmpty()) { + error("部署顺序不能为空,请输入如AB、BA的顺序") + } + + orderChars.each { instance -> + if (!selectedTargets.contains(instance)) { + error("部署顺序包含未选择的实例: ${instance},已选实例:${params.DEPLOY_TARGETS}") + } + } + + def uniqueOrder = orderChars.unique() + if (uniqueOrder.size() != orderChars.size()) { + error("部署顺序包含重复实例: ${params.DEPLOY_ORDER}") + } + + echo "✅ 参数验证通过:已选实例=${selectedTargets},部署顺序=${orderChars}" + env.VALID_ORDER = params.DEPLOY_ORDER + } + + stage('动态部署') { + def orderChars = env.VALID_ORDER.split('').toList() + orderChars.each { instance -> + echo "===== 开始部署实例 ${instance} =====" + + stage("${instance}下线&同步") { + def cfg = config[instance] + sh "ssh ${cfg.remoteHost} 'sh ${cfg.killScript} ${cfg.port}'" + sh """ + ssh ${cfg.remoteHost} 'mkdir -p ${cfg.projectPath}' + rsync -avz --exclude '.venv' --exclude '.git' ${WORKSPACE}/ ${cfg.remoteHost}:${cfg.projectPath}/ + """ + } + + stage("${instance}依赖&启动") { + def cfg = config[instance] + sh """ + ssh ${cfg.remoteHost} ' + cd ${cfg.projectPath} + uv sync + source ${cfg.venvDir}/bin/activate + TIMESTAMP=\$(date +"%Y%m%d_%H%M%S") + LOGFILE="${cfg.projectPath}/logs/lessie_sourcing_agents_\${TIMESTAMP}.log" + nohup env APP_ENV=s5 gunicorn -w ${cfg.gunicornWorkers} -k uvicorn.workers.UvicornWorker \ + -b 0.0.0.0:${cfg.port} --timeout 300 dialogue.app:app \ + --max-requests 200 --max-requests-jitter 50 \ + > "\$LOGFILE" 2>&1 & + ln -sf "\$LOGFILE" ${cfg.projectPath}/logs/lessie_sourcing_agents_latest.log + ' + """ + } + + stage("探测${instance}探测服务") { + def cfg = config[instance] + sh "sleep 5" + sh "ssh ${cfg.remoteHost} 'head -n 300 ${cfg.projectPath}/logs/lessie_sourcing_agents_latest.log | grep -i error || echo 未发现错误日志'" + sh "ssh ${cfg.remoteHost} 'sh ${cfg.checkScript}'" + } + + echo "===== 实例 ${instance} 部署完成 =====" + } + } + + echo '✅ 所有选中的实例部署成功!' +} diff --git a/jenkins/流水线配置/s5.jennie.im_web.conf b/jenkins/流水线配置/s5.jennie.im_web.conf new file mode 100644 index 0000000..602c879 --- /dev/null +++ b/jenkins/流水线配置/s5.jennie.im_web.conf @@ -0,0 +1,66 @@ +pipeline { + agent any + + parameters { + gitParameter( + branchFilter: 'origin/(.*)', + defaultValue: 'dev', + name: 'Code_branch', + type: 'PT_BRANCH_TAG', + selectedValue: 'DEFAULT', + sortMode: 'NONE', + description: '选择代码分支或标签: ', + quickFilterEnabled: true, + tagFilter: '*', + listSize: "1" + ) + } + environment { + WEB_HOST_IP = "43.130.56.138" + WEB_HOST_PROJECT_PATH = "/data/tengine/html/s5-jennie-im-web/dist" + } + + stages { + stage('拉取代码') { + steps { + git branch: "${params.Code_branch}", credentialsId: 'fly_gitlab_auth', url: 'http://172.24.16.20/web/jennie.git' + } + } + + stage('pnpm i&b') { + steps { + script { + sh """ + export PATH="/data/node-v20.15.0/bin:$PATH" + echo "开始安装依赖包" + cd ${WORKSPACE}/ && rm -rf node_modules && pnpm install + echo "开始构建" + pnpm build:im + mv dist/main/index.html dist/ + chmod -R 755 dist/ + """ + } + } + } + + stage('同步产物') { + steps { + script { + sh """ + cd ${WORKSPACE}/ + rsync -avzP --delete dist/ ${WEB_HOST_IP}:${WEB_HOST_PROJECT_PATH} + """ + } + } + } + } + + post { + success { + echo "构建成功!" + } + failure { + echo "构建失败!" + } + } +} \ No newline at end of file diff --git a/jenkins/流水线配置/s6.jennie.im.conf b/jenkins/流水线配置/s6.jennie.im.conf new file mode 100644 index 0000000..eee2467 --- /dev/null +++ b/jenkins/流水线配置/s6.jennie.im.conf @@ -0,0 +1,123 @@ +node { + properties([ + parameters([ + // 分支选择参数 + gitParameter( + branchFilter: 'origin/(.*)', + defaultValue: 'master', + description: 's4环境,默认master分支', + name: 'Code_branch', + quickFilterEnabled: true, + selectedValue: 'DEFAULT', + sortMode: 'NONE', + type: 'PT_BRANCH', + size: 1 + ), + // 部署实例选择 + choice( + name: 'DEPLOY_TARGETS', + choices: ['A'], + description: '选择需要部署的实例' + ), + // 部署顺序 + string( + name: 'DEPLOY_ORDER', + defaultValue: 'A', + description: '指定部署顺序' + ) + ]) + ]) + + // 环境配置(集中管理实例参数) + def config = [ + A: [ + remoteHost: "49.51.33.153", + projectPath: "/data/webapps/lessie_sourcing_agents_s6", + venvDir: "/data/webapps/lessie_sourcing_agents_s6/.venv", + port: "8001", + killScript: "/data/sh/kill_lessie_sourcing_agents.sh", + checkScript: "/data/sh/check_lessie_agents_8001.sh", + gunicornWorkers: 4 + ], + ] + + + stage('拉代码') { + checkout scm: [ + $class: 'GitSCM', + branches: [[name: params.Code_branch]], + userRemoteConfigs: [[ + url: 'http://172.24.16.20/python/lessie-sourcing-agents.git', + credentialsId: 'fly_gitlab_auth' + ]] + ] + } + + stage('验证参数') { + def selectedTargets = params.DEPLOY_TARGETS.split(',').toList() + def orderChars = params.DEPLOY_ORDER.split('').toList() + + if (orderChars.isEmpty()) { + error("部署顺序不能为空,请输入如AB、BA的顺序") + } + + orderChars.each { instance -> + if (!selectedTargets.contains(instance)) { + error("部署顺序包含未选择的实例: ${instance},已选实例:${params.DEPLOY_TARGETS}") + } + } + + def uniqueOrder = orderChars.unique() + if (uniqueOrder.size() != orderChars.size()) { + error("部署顺序包含重复实例: ${params.DEPLOY_ORDER}") + } + + echo "✅ 参数验证通过:已选实例=${selectedTargets},部署顺序=${orderChars}" + env.VALID_ORDER = params.DEPLOY_ORDER + } + + stage('动态部署') { + def orderChars = env.VALID_ORDER.split('').toList() + orderChars.each { instance -> + echo "===== 开始部署实例 ${instance} =====" + + stage("${instance}下线&同步") { + def cfg = config[instance] + sh "ssh ${cfg.remoteHost} 'sh ${cfg.killScript} ${cfg.port}'" + sh """ + ssh ${cfg.remoteHost} 'mkdir -p ${cfg.projectPath}' + rsync -avz --exclude '.venv' --exclude '.git' ${WORKSPACE}/ ${cfg.remoteHost}:${cfg.projectPath}/ + """ + } + + stage("${instance}依赖&启动") { + def cfg = config[instance] + sh """ + ssh ${cfg.remoteHost} ' + cd ${cfg.projectPath} + uv sync + source ${cfg.venvDir}/bin/activate + TIMESTAMP=\$(date +"%Y%m%d_%H%M%S") + LOGFILE="${cfg.projectPath}/logs/lessie_sourcing_agents_\${TIMESTAMP}.log" + nohup env APP_ENV=s6 gunicorn -w ${cfg.gunicornWorkers} -k uvicorn.workers.UvicornWorker \ + -b 0.0.0.0:${cfg.port} --timeout 300 dialogue.app:app \ + --max-requests 200 --max-requests-jitter 50 \ + > "\$LOGFILE" 2>&1 & + ln -sf "\$LOGFILE" ${cfg.projectPath}/logs/lessie_sourcing_agents_latest.log + ' + """ + } + + stage("探测${instance}探测服务") { + def cfg = config[instance] + sh "sleep 5" + sh "ssh ${cfg.remoteHost} 'head -n 300 ${cfg.projectPath}/logs/lessie_sourcing_agents_latest.log | grep -i error || echo 未发现错误日志'" + sh "ssh ${cfg.remoteHost} 'sh ${cfg.checkScript}'" + } + + echo "===== 实例 ${instance} 部署完成 =====" + } + } + + echo '✅ 所有选中的实例部署成功!' +} diff --git a/jenkins/流水线配置/s6.jennie.im_web.conf b/jenkins/流水线配置/s6.jennie.im_web.conf new file mode 100644 index 0000000..f2cedcf --- /dev/null +++ b/jenkins/流水线配置/s6.jennie.im_web.conf @@ -0,0 +1,66 @@ +pipeline { + agent any + + parameters { + gitParameter( + branchFilter: 'origin/(.*)', + defaultValue: 'dev', + name: 'Code_branch', + type: 'PT_BRANCH_TAG', + selectedValue: 'DEFAULT', + sortMode: 'NONE', + description: '选择代码分支或标签: ', + quickFilterEnabled: true, + tagFilter: '*', + listSize: "1" + ) + } + environment { + WEB_HOST_IP = "43.130.56.138" + WEB_HOST_PROJECT_PATH = "/data/tengine/html/s6-jennie-im-web/dist" + } + + stages { + stage('拉取代码') { + steps { + git branch: "${params.Code_branch}", credentialsId: 'fly_gitlab_auth', url: 'http://172.24.16.20/web/jennie.git' + } + } + + stage('pnpm i&b') { + steps { + script { + sh """ + export PATH="/data/node-v20.15.0/bin:$PATH" + echo "开始安装依赖包" + cd ${WORKSPACE}/ && rm -rf node_modules && pnpm install + echo "开始构建" + pnpm build:im + mv dist/main/index.html dist/ + chmod -R 755 dist/ + """ + } + } + } + + stage('同步产物') { + steps { + script { + sh """ + cd ${WORKSPACE}/ + rsync -avzP --delete dist/ ${WEB_HOST_IP}:${WEB_HOST_PROJECT_PATH} + """ + } + } + } + } + + post { + success { + echo "构建成功!" + } + failure { + echo "构建失败!" + } + } +} \ No newline at end of file diff --git a/jenkins/流水线配置/sit_jenniefy_web.conf b/jenkins/流水线配置/sit_jenniefy_web.conf index 7b73e30..1489ceb 100644 --- a/jenkins/流水线配置/sit_jenniefy_web.conf +++ b/jenkins/流水线配置/sit_jenniefy_web.conf @@ -59,7 +59,7 @@ node -v npm -v pnpm -v #cd /data/.jenkins/workspace/sit_jenniefy_web/projects/jennie/ -rm -rf dist/ +#rm -rf dist/ rm -rf node_modules/ pnpm install --registry=http://mirrors.cloud.tencent.com/npm/ --force pnpm run build:jennie diff --git a/jenkins/流水线配置/xxl-job/sit.application.properties b/jenkins/流水线配置/xxl-job/sit.application.properties new file mode 100644 index 0000000..4e9ecb8 --- /dev/null +++ b/jenkins/流水线配置/xxl-job/sit.application.properties @@ -0,0 +1,74 @@ +### web +server.port=7070 +server.servlet.context-path=/xxl-job-admin + +### actuator +management.endpoints.web.base-path=/actuator +management.health.mail.enabled=false + +### resources +spring.mvc.servlet.load-on-startup=0 +spring.mvc.static-path-pattern=/static/** +spring.web.resources.static-locations=classpath:/static/ + +### freemarker +spring.freemarker.templateLoaderPath=classpath:/templates/ +spring.freemarker.suffix=.ftl +spring.freemarker.charset=UTF-8 +spring.freemarker.request-context-attribute=request +spring.freemarker.settings.number_format=0.########## +spring.freemarker.settings.new_builtin_class_resolver=safer + +### mybatis +mybatis.mapper-locations=classpath:/mapper/*Mapper.xml + +### datasource-pool +spring.datasource.type=com.zaxxer.hikari.HikariDataSource +spring.datasource.hikari.minimum-idle=10 +spring.datasource.hikari.maximum-pool-size=30 +spring.datasource.hikari.auto-commit=true +spring.datasource.hikari.idle-timeout=30000 +spring.datasource.hikari.pool-name=HikariCP +spring.datasource.hikari.max-lifetime=900000 +spring.datasource.hikari.connection-timeout=10000 +spring.datasource.hikari.connection-test-query=SELECT 1 +spring.datasource.hikari.validation-timeout=1000 + +### xxl-job, datasource +spring.datasource.url=jdbc:mysql://10.0.0.10:3306/xxl_job?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai +spring.datasource.username=system +spring.datasource.password=System8888! +spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver + +### xxl-job, email +spring.mail.host= +spring.mail.port= +spring.mail.username= +spring.mail.from= +spring.mail.password= +spring.mail.properties.mail.smtp.auth=true +spring.mail.properties.mail.smtp.starttls.enable=true +spring.mail.properties.mail.smtp.starttls.required=true +spring.mail.properties.mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory + +### xxl-job, access token +xxl.job.accessToken=default_token + +### xxl-job, timeout +xxl.job.timeout=3 + +### xxl-job, i18n (default is zh_CN, and you can choose "zh_CN", "zh_TC" and "en") +xxl.job.i18n=zh_CN + +## xxl-job, triggerpool max size +xxl.job.triggerpool.fast.max=200 +xxl.job.triggerpool.slow.max=100 + +### xxl-job, log retention days +xxl.job.logretentiondays=30 + +### xxl-sso +xxl-sso.token.key=xxl_job_login_token +xxl-sso.token.timeout=604800000 +xxl-sso.client.excluded.paths= +xxl-sso.client.login.path=/auth/login diff --git a/nginx/s5.jennie.im.conf b/nginx/s5.jennie.im.conf new file mode 100644 index 0000000..a534bb5 --- /dev/null +++ b/nginx/s5.jennie.im.conf @@ -0,0 +1,204 @@ +# ============10-30============================================== + +upstream s5_jennie_im_backend { + server 10.0.0.38:8000 weight=10 max_fails=3 fail_timeout=30s; + keepalive 128; +} + + +log_format s5_jennie_im_log '客户端IP: $remote_addr | 用户: $remote_user | 时间: $time_local | ' + '请求方法和路径: "$request" | 状态码: $status | 响应大小: $body_bytes_sent | ' + '来源页面: "$http_referer" | 客户端UA: "$http_user_agent" | ' + '上游服务器: $upstream_addr | 上游响应耗时: $upstream_response_time | ' + '请求总耗时: $request_time | Host: $host'; + +server { + listen 443 ssl; + server_name s5.jennie.im; + + ssl_certificate /data/tengine/conf/certificate/jennie.im.crt; + ssl_certificate_key /data/tengine/conf/certificate/jennie.im.key; + ssl_protocols TLSv1.2 TLSv1.3; + ssl_ciphers HIGH:!aNULL:!MD5; + + # 单独日志文件 + access_log /data/tengine/logs/s5_jennie_im_access.log s5_jennie_im_log; + error_log /data/tengine/logs/s5_jennie_im_error.log; + + + # 前端静态文件 + location / { + root /data/tengine/html/s5-jennie-im-web/dist; + index index.html; + + try_files $uri $uri/ /index.html; + } + + # 精确匹配 index.html,禁用缓存 + location = /index.html { + root /data/tengine/html/s5-jennie-im-web/dist; + add_header Cache-Control "no-cache, no-store, must-revalidate"; + } + # 静态资源开启长缓存(带 hash) + location ~* \.(js|css|woff2|json|svg|png|jpg|jpeg|gif|ico|ttf|otf|eot|mp4|webm|webp)$ { + root /data/tengine/html/s5-jennie-im-web/dist; + add_header Cache-Control "public, max-age=31536000, immutable"; + } + + + # go的代理配置 + location ~ ^/(debug/pprof|api/chat|api/conversation/|api/shares|api/showcases|api/searches) { + proxy_pass http://10.0.0.38:8100; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + + proxy_buffering off; + proxy_cache off; + proxy_http_version 1.1; + proxy_set_header Connection ""; + proxy_request_buffering off; + + add_header 'Access-Control-Allow-Origin' "$http_origin" always; + add_header 'Access-Control-Allow-Credentials' 'true' always; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE' always; + add_header 'Access-Control-Allow-Headers' 'Authorization,Content-Type,X-Requested-With,Accept,Origin' always; + + if ($request_method = OPTIONS ) { + return 204; + } + } + + + location /api/chat/stream { + proxy_pass http://s5_jennie_im_backend; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + + proxy_buffering off; + proxy_cache off; + proxy_http_version 1.1; + proxy_set_header Connection ""; + proxy_request_buffering off; + + add_header 'Access-Control-Allow-Origin' "$http_origin" always; + add_header 'Access-Control-Allow-Credentials' 'true' always; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE' always; + add_header 'Access-Control-Allow-Headers' 'Authorization,Content-Type,X-Requested-With,Accept,Origin' always; + + # 增加客户端到Nginx的连接超时时间 + proxy_read_timeout 3600s; + proxy_send_timeout 3600s; + + if ($request_method = OPTIONS ) { + return 204; + } + } + + location /api/ { + proxy_pass http://s5_jennie_im_backend; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + + proxy_buffering off; + proxy_cache off; + proxy_http_version 1.1; + proxy_set_header Connection ""; + proxy_request_buffering off; + + add_header 'Access-Control-Allow-Origin' "$http_origin" always; + add_header 'Access-Control-Allow-Credentials' 'true' always; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE' always; + add_header 'Access-Control-Allow-Headers' 'Authorization,Content-Type,X-Requested-With,Accept,Origin' always; + + if ($request_method = OPTIONS ) { + return 204; + } + } + + + # sit的支付模块 + location /payment/webhook/ { + proxy_pass http://106.53.194.199:8010; #运维机器的8010(与容器的8090映射)代理到sit的8090 + proxy_set_header Host 106.53.194.199; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + + proxy_intercept_errors off; + proxy_buffering off; + proxy_cache off; + proxy_set_header Connection keep-alive; + + add_header 'Access-Control-Allow-Origin' "$http_origin" always; + add_header 'Access-Control-Allow-Credentials' 'true' always; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE' always; + add_header 'Access-Control-Allow-Headers' 'Authorization,Content-Type,X-Requested-With,Accept,Origin' always; + + if ($request_method = OPTIONS ) { + return 204; + } + } + + + # 打到国内sit的agent.jar包 + location /sit-api/agent/ { + proxy_pass http://106.53.194.199:8070; + proxy_set_header Host 106.53.194.199; + + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + + proxy_intercept_errors off; + proxy_buffering off; + proxy_cache off; + proxy_set_header Connection keep-alive; + + client_max_body_size 300M; + + add_header 'Access-Control-Allow-Origin' "$http_origin" always; + add_header 'Access-Control-Allow-Credentials' 'true' always; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE' always; + add_header 'Access-Control-Allow-Headers' 'Authorization,Content-Type,X-Requested-With,Accept,Origin' always; + + if ($request_method = OPTIONS ) { + return 204; + } + } + + + location /sit-api/system { + proxy_pass http://106.53.194.199:8070; + proxy_set_header Host 106.53.194.199; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + + proxy_intercept_errors off; + proxy_buffering off; + proxy_cache off; + proxy_set_header Connection keep-alive; + + add_header 'Access-Control-Allow-Origin' "$http_origin" always; + add_header 'Access-Control-Allow-Credentials' 'true' always; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE' always; + add_header 'Access-Control-Allow-Headers' 'Authorization,Content-Type,X-Requested-With,Accept,Origin' always; + + client_max_body_size 300M; + + if ($request_method = OPTIONS ) { + return 204; + } + } + + # 错误页面 + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /data/tengine/html/s5-jennie/dist; + } +} + +# ====================10-30======================================== \ No newline at end of file diff --git a/nginx/s6.jennie.im.conf b/nginx/s6.jennie.im.conf new file mode 100644 index 0000000..68cf478 --- /dev/null +++ b/nginx/s6.jennie.im.conf @@ -0,0 +1,204 @@ +# ============10-30============================================== + +upstream s6_jennie_im_backend { + server 10.0.0.38:8001 weight=10 max_fails=3 fail_timeout=30s; + keepalive 128; +} + + +log_format s6_jennie_im_log '客户端IP: $remote_addr | 用户: $remote_user | 时间: $time_local | ' + '请求方法和路径: "$request" | 状态码: $status | 响应大小: $body_bytes_sent | ' + '来源页面: "$http_referer" | 客户端UA: "$http_user_agent" | ' + '上游服务器: $upstream_addr | 上游响应耗时: $upstream_response_time | ' + '请求总耗时: $request_time | Host: $host'; + +server { + listen 443 ssl; + server_name s6.jennie.im; + + ssl_certificate /data/tengine/conf/certificate/jennie.im.crt; + ssl_certificate_key /data/tengine/conf/certificate/jennie.im.key; + ssl_protocols TLSv1.2 TLSv1.3; + ssl_ciphers HIGH:!aNULL:!MD5; + + # 单独日志文件 + access_log /data/tengine/logs/s6_jennie_im_access.log s6_jennie_im_log; + error_log /data/tengine/logs/s6_jennie_im_error.log; + + + # 前端静态文件 + location / { + root /data/tengine/html/s6-jennie-im-web/dist; + index index.html; + + try_files $uri $uri/ /index.html; + } + + # 精确匹配 index.html,禁用缓存 + location = /index.html { + root /data/tengine/html/s6-jennie-im-web/dist; + add_header Cache-Control "no-cache, no-store, must-revalidate"; + } + # 静态资源开启长缓存(带 hash) + location ~* \.(js|css|woff2|json|svg|png|jpg|jpeg|gif|ico|ttf|otf|eot|mp4|webm|webp)$ { + root /data/tengine/html/s6-jennie-im-web/dist; + add_header Cache-Control "public, max-age=31536000, immutable"; + } + + + # go的代理配置 + location ~ ^/(debug/pprof|api/chat|api/conversation/|api/shares|api/showcases|api/searches) { + proxy_pass http://10.0.0.38:8101; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + + proxy_buffering off; + proxy_cache off; + proxy_http_version 1.1; + proxy_set_header Connection ""; + proxy_request_buffering off; + + add_header 'Access-Control-Allow-Origin' "$http_origin" always; + add_header 'Access-Control-Allow-Credentials' 'true' always; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE' always; + add_header 'Access-Control-Allow-Headers' 'Authorization,Content-Type,X-Requested-With,Accept,Origin' always; + + if ($request_method = OPTIONS ) { + return 204; + } + } + + + location /api/chat/stream { + proxy_pass http://s6_jennie_im_backend; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + + proxy_buffering off; + proxy_cache off; + proxy_http_version 1.1; + proxy_set_header Connection ""; + proxy_request_buffering off; + + add_header 'Access-Control-Allow-Origin' "$http_origin" always; + add_header 'Access-Control-Allow-Credentials' 'true' always; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE' always; + add_header 'Access-Control-Allow-Headers' 'Authorization,Content-Type,X-Requested-With,Accept,Origin' always; + + # 增加客户端到Nginx的连接超时时间 + proxy_read_timeout 3600s; + proxy_send_timeout 3600s; + + if ($request_method = OPTIONS ) { + return 204; + } + } + + location /api/ { + proxy_pass http://s6_jennie_im_backend; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + + proxy_buffering off; + proxy_cache off; + proxy_http_version 1.1; + proxy_set_header Connection ""; + proxy_request_buffering off; + + add_header 'Access-Control-Allow-Origin' "$http_origin" always; + add_header 'Access-Control-Allow-Credentials' 'true' always; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE' always; + add_header 'Access-Control-Allow-Headers' 'Authorization,Content-Type,X-Requested-With,Accept,Origin' always; + + if ($request_method = OPTIONS ) { + return 204; + } + } + + + # sit的支付模块 + location /payment/webhook/ { + proxy_pass http://106.53.194.199:8010; #运维机器的8010(与容器的8090映射)代理到sit的8090 + proxy_set_header Host 106.53.194.199; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + + proxy_intercept_errors off; + proxy_buffering off; + proxy_cache off; + proxy_set_header Connection keep-alive; + + add_header 'Access-Control-Allow-Origin' "$http_origin" always; + add_header 'Access-Control-Allow-Credentials' 'true' always; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE' always; + add_header 'Access-Control-Allow-Headers' 'Authorization,Content-Type,X-Requested-With,Accept,Origin' always; + + if ($request_method = OPTIONS ) { + return 204; + } + } + + + # 打到国内sit的agent.jar包 + location /sit-api/agent/ { + proxy_pass http://106.53.194.199:8070; + proxy_set_header Host 106.53.194.199; + + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + + proxy_intercept_errors off; + proxy_buffering off; + proxy_cache off; + proxy_set_header Connection keep-alive; + + client_max_body_size 300M; + + add_header 'Access-Control-Allow-Origin' "$http_origin" always; + add_header 'Access-Control-Allow-Credentials' 'true' always; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE' always; + add_header 'Access-Control-Allow-Headers' 'Authorization,Content-Type,X-Requested-With,Accept,Origin' always; + + if ($request_method = OPTIONS ) { + return 204; + } + } + + + location /sit-api/system { + proxy_pass http://106.53.194.199:8070; + proxy_set_header Host 106.53.194.199; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + + proxy_intercept_errors off; + proxy_buffering off; + proxy_cache off; + proxy_set_header Connection keep-alive; + + add_header 'Access-Control-Allow-Origin' "$http_origin" always; + add_header 'Access-Control-Allow-Credentials' 'true' always; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE' always; + add_header 'Access-Control-Allow-Headers' 'Authorization,Content-Type,X-Requested-With,Accept,Origin' always; + + client_max_body_size 300M; + + if ($request_method = OPTIONS ) { + return 204; + } + } + + # 错误页面 + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /data/tengine/html/s6-jennie/dist; + } +} + +# ====================10-30======================================== \ No newline at end of file