From 4938635ef4537f72a49911b9b6cb0f1e34be3d0c Mon Sep 17 00:00:00 2001 From: whyour Date: Fri, 20 Oct 2023 17:54:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9C=8D=E5=8A=A1=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E6=97=B6=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8F=E6=B1=A1?= =?UTF-8?q?=E6=9F=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/loaders/initFile.ts | 2 -- docker/docker-entrypoint.sh | 1 + shell/env.sh | 15 +++++++++++++++ shell/share.sh | 4 ++-- shell/update.sh | 1 + 5 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 shell/env.sh diff --git a/back/loaders/initFile.ts b/back/loaders/initFile.ts index 65e7ed46..3d9b7441 100644 --- a/back/loaders/initFile.ts +++ b/back/loaders/initFile.ts @@ -108,8 +108,6 @@ export default async () => { fs.writeFileSync(TaskAfterFile, fs.readFileSync(sampleTaskShellFile)); } - dotenv.config({ path: confFile }); - Logger.info('✌️ Init file down'); console.log('✌️ Init file down'); }; diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh index 5e706c91..c81b7d67 100755 --- a/docker/docker-entrypoint.sh +++ b/docker/docker-entrypoint.sh @@ -1,6 +1,7 @@ #!/bin/bash dir_shell=/ql/shell +. $dir_shell/env.sh . $dir_shell/share.sh link_shell diff --git a/shell/env.sh b/shell/env.sh new file mode 100644 index 00000000..4d7dcff7 --- /dev/null +++ b/shell/env.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +store_env_vars() { + initial_vars=($(compgen -A variable)) +} + +restore_env_vars() { + for key in $(compgen -A variable); do + if ! [[ " ${initial_vars[@]} " =~ " $key " ]]; then + unset "$key" + fi + done +} + +store_env_vars diff --git a/shell/share.sh b/shell/share.sh index f6b6a0b9..d1f57c40 100755 --- a/shell/share.sh +++ b/shell/share.sh @@ -19,7 +19,6 @@ dir_update_log=$dir_log/update ql_static_repo=$dir_repo/static ## 文件 -file_ecosystem_js=$dir_root/ecosystem.config.js file_config_sample=$dir_sample/config.sample.sh file_env=$dir_config/env.sh file_sharecode=$dir_config/sharecode.sh @@ -308,8 +307,9 @@ random_range() { reload_pm2() { cd $dir_root + restore_env_vars pm2 flush &>/dev/null - env ALL_PROXY= HTTP_PROXY= HTTPS_PROXY= all_proxy= http_proxy= https_proxy= pm2 startOrGracefulReload $file_ecosystem_js --update-env + pm2 startOrGracefulReload ecosystem.config.js } diff_time() { diff --git a/shell/update.sh b/shell/update.sh index 94224ea3..33f1b3b9 100755 --- a/shell/update.sh +++ b/shell/update.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash dir_shell=$QL_DIR/shell +. $dir_shell/env.sh . $dir_shell/share.sh . $dir_shell/api.sh