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, }, }, ],