diff --git a/back/public.ts b/back/public.ts index 056f748c..ea04986c 100644 --- a/back/public.ts +++ b/back/public.ts @@ -1,5 +1,4 @@ import express from 'express'; -import { exec } from 'child_process'; import Logger from './loaders/logger'; import config from './config'; import { HealthClient } from './protos/health'; diff --git a/docker/Dockerfile b/docker/Dockerfile index 53cc3550..52a69504 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -5,7 +5,7 @@ RUN set -x \ && apk add nodejs npm git \ && npm i -g pnpm \ && cd /tmp/build \ - && pnpm install --prod + && pnpm --registry https://registry.npmmirror.com install --prod FROM python:3.10-alpine @@ -50,6 +50,7 @@ RUN set -x \ && git config --global user.name "qinglong" \ && git config --global http.postBuffer 524288000 \ && npm install -g pnpm \ + && cd && pnpm config set registry https://registry.npmmirror.com \ && pnpm add -g pm2 tsx \ && rm -rf /root/.pnpm-store \ && rm -rf /root/.local/share/pnpm/store \ diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh index 4b65b490..d2d7ccc6 100755 --- a/docker/docker-entrypoint.sh +++ b/docker/docker-entrypoint.sh @@ -16,6 +16,14 @@ pm2 flush &>/dev/null echo -e "======================2. 安装依赖========================\n" patch_version +if [[ $PipMirror ]]; then + pip3 config set global.index-url $PipMirror +fi +current_npm_registry=$(cd && pnpm config get registry) +if [[ $current_npm_registry != $NpmMirror ]]; then + cd && pnpm config set registry $NpmMirror + pnpm install -g --force +fi update_depend echo @@ -23,21 +31,21 @@ echo -e "======================3. 启动nginx========================\n" nginx -s reload 2>/dev/null || nginx -c /etc/nginx/nginx.conf echo -e "nginx启动成功...\n" -echo -e "======================4. 启动面板监控========================\n" +echo -e "======================4. 启动定时服务========================\n" +pm2 delete schedule &>/dev/null +pm2 start $dir_static/build/schedule/index.js -n schedule --source-map-support --time +echo -e "定时任务启动成功...\n" + +echo -e "======================5. 启动面板监控========================\n" pm2 delete public &>/dev/null pm2 start $dir_static/build/public.js -n public --source-map-support --time echo -e "监控服务启动成功...\n" -echo -e "======================5. 启动主服务========================\n" +echo -e "======================6. 启动主服务========================\n" pm2 delete panel &>/dev/null pm2 start $dir_static/build/app.js -n panel --source-map-support --time echo -e "主服务启动成功...\n" -echo -e "======================6. 启动定时服务========================\n" -pm2 delete schedule &>/dev/null -pm2 start $dir_static/build/schedule/index.js -n schedule --source-map-support --time -echo -e "定时任务启动成功...\n" - if [[ $AutoStartBot == true ]]; then echo -e "======================7. 启动bot========================\n" nohup ql -l bot >$dir_log/bot.log 2>&1 & diff --git a/shell/check.sh b/shell/check.sh index 97fe1312..71a9da3c 100755 --- a/shell/check.sh +++ b/shell/check.sh @@ -6,11 +6,13 @@ reset_env() { echo -e "---> 配置文件检测完成\n" echo -e "---> 2. 开始安装青龙依赖\n" + rm -rf $dir_root/node_modules npm_install_2 $dir_root echo -e "---> 青龙依赖安装完成\n" echo -e "---> 3. 开始安装脚本依赖\n" cp -f $dir_sample/package.json $dir_scripts/package.json + rm -rf $dir_scripts/node_modules npm_install_2 $dir_scripts echo -e "---> 脚本依赖安装完成\n" } @@ -84,6 +86,17 @@ main() { echo -e "=====> 开始检测" npm i -g pnpm patch_version + + apk add procps + + if [[ $PipMirror ]]; then + pip3 config set global.index-url $PipMirror + fi + if [[ $NpmMirror ]]; then + cd && pnpm config set registry $NpmMirror + pnpm install -g --force + fi + pnpm add -g pm2 tsx reset_env start_public diff --git a/shell/share.sh b/shell/share.sh index d3a72657..b23124e9 100755 --- a/shell/share.sh +++ b/shell/share.sh @@ -262,17 +262,6 @@ npm_install_sub() { fi } -npm_install_1() { - local dir_current=$(pwd) - local dir_work=$1 - - cd $dir_work - echo -e "运行 pnpm install...\n" - npm_install_sub - [[ $? -ne 0 ]] && echo -e "\nnpm install 运行不成功,请进入 $dir_work 目录后手动运行 pnpm install...\n" - cd $dir_current -} - npm_install_2() { local dir_current=$(pwd) local dir_work=$1 @@ -280,10 +269,6 @@ npm_install_2() { cd $dir_work echo -e "安装 $dir_work 依赖包...\n" npm_install_sub - if [[ $? -ne 0 ]]; then - echo -e "\n安装 $dir_work 的依赖包运行不成功,再次尝试一遍...\n" - npm_install_1 $dir_work - fi cd $dir_current } @@ -440,19 +425,6 @@ format_timestamp() { } patch_version() { - # 兼容pnpm@7 - pnpm setup &>/dev/null - source ~/.bashrc - apk add procps - - if [[ $PipMirror ]]; then - pip3 config set global.index-url $PipMirror - fi - if [[ $NpmMirror ]]; then - cd && pnpm config set registry $NpmMirror - pnpm install -g --force - fi - git config --global pull.rebase false cp -f $dir_root/.env.example $dir_root/.env