From bf50404b3e531401d04ed4df6abcc90751f43688 Mon Sep 17 00:00:00 2001 From: liudongqi Date: Wed, 4 Sep 2024 10:15:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=AF=E5=8A=A8=E8=84=9A=E6=9C=AC=E6=9B=B4?= =?UTF-8?q?=E5=8F=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy.sh | 12 ++++++++++-- ecosystem.config.js | 13 +++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/deploy.sh b/deploy.sh index 12de23d..4163ded 100644 --- a/deploy.sh +++ b/deploy.sh @@ -1,11 +1,19 @@ #!/bin/bash APP_NAME="qry-python-js" +activate=$1 +if [ "$activate" == "" ]; then + activate=dev + echo "未设置环境变量参数 默认:dev" +fi + +echo "启动环境 $activate" + #source /usr/share/nvm/init-nvm.sh nvm use 20 if pm2 status | grep -q "$APP_NAME.*online"; then echo "Application $APP_NAME is running." - pm2 restart $APP_NAME + pm2 restart ecosystem.config.js --env $activate else echo "Application $APP_NAME is not running." - pm2 start + pm2 start ecosystem.config.js --env $activate fi \ No newline at end of file diff --git a/ecosystem.config.js b/ecosystem.config.js index 615a7cc..658b330 100644 --- a/ecosystem.config.js +++ b/ecosystem.config.js @@ -10,16 +10,21 @@ module.exports = { // 使用集群模式 exec_mode: 'cluster', watch: true, - env: { + env_dev: { // 开发环境的环境变量 NODE_ENV: 'development', PORT: 8081 }, - env_production: { + env_uat: { + // 开发环境的环境变量 + NODE_ENV: 'uat', + PORT: 58081 + }, + env_prod: { // 生产环境的环境变量 - NODE_ENV: 'production', + NODE_ENV: 'prod', // 自定义环境变量示例 - PORT: 80, + PORT: 58081, }, }, ],