mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-23 14:56:07 +08:00
修复 npm 启动脚本
This commit is contained in:
parent
7405ca6cc8
commit
d60ca49c7e
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# 前置依赖 nodejs、npm
|
# 前置依赖 nodejs、npm、python3
|
||||||
set -e
|
set -e
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
|
@ -68,6 +68,18 @@ fi
|
||||||
|
|
||||||
npm install -g pnpm@8.3.1 pm2 ts-node
|
npm install -g pnpm@8.3.1 pm2 ts-node
|
||||||
|
|
||||||
|
export PYTHON_SHORT_VERSION=$(python3 -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')
|
||||||
|
export PNPM_HOME=${QL_DIR}/data/dep_cache/node
|
||||||
|
export PYTHON_HOME=${QL_DIR}/data/dep_cache/python3
|
||||||
|
export PYTHONUSERBASE=${QL_DIR}/data/dep_cache/python3
|
||||||
|
|
||||||
|
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${PNPM_HOME}:${PYTHON_HOME}/bin
|
||||||
|
export NODE_PATH=/usr/local/bin:/usr/local/lib/node_modules:${PNPM_HOME}/global/5/node_modules
|
||||||
|
export PIP_CACHE_DIR=${PYTHON_HOME}/pip
|
||||||
|
export PYTHONPATH=${PYTHON_HOME}:${PYTHON_HOME}/lib/python${PYTHON_SHORT_VERSION}:${PYTHON_HOME}/lib/python${PYTHON_SHORT_VERSION}/site-packages
|
||||||
|
|
||||||
|
pip3 install --prefix ${PYTHON_HOME} requests
|
||||||
|
|
||||||
cd ${QL_DIR}
|
cd ${QL_DIR}
|
||||||
cp -f .env.example .env
|
cp -f .env.example .env
|
||||||
chmod 777 ${QL_DIR}/shell/*.sh
|
chmod 777 ${QL_DIR}/shell/*.sh
|
||||||
|
@ -75,7 +87,15 @@ chmod 777 ${QL_DIR}/shell/*.sh
|
||||||
. ${QL_DIR}/shell/share.sh
|
. ${QL_DIR}/shell/share.sh
|
||||||
. ${QL_DIR}/shell/env.sh
|
. ${QL_DIR}/shell/env.sh
|
||||||
|
|
||||||
echo -e "======================1. 检测配置文件========================\n"
|
log_with_style() {
|
||||||
|
local level="$1"
|
||||||
|
local message="$2"
|
||||||
|
local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
|
||||||
|
|
||||||
|
printf "\n[%s] [%7s] %s\n" "${timestamp}" "${level}" "${message}"
|
||||||
|
}
|
||||||
|
|
||||||
|
log_with_style "INFO" "🚀 1. 检测配置文件..."
|
||||||
import_config "$@"
|
import_config "$@"
|
||||||
make_dir /etc/nginx/conf.d
|
make_dir /etc/nginx/conf.d
|
||||||
make_dir /run/nginx
|
make_dir /run/nginx
|
||||||
|
@ -84,31 +104,23 @@ fix_config
|
||||||
|
|
||||||
pm2 l &>/dev/null
|
pm2 l &>/dev/null
|
||||||
|
|
||||||
echo -e "======================2. 安装依赖========================\n"
|
log_with_style "INFO" "🔄 2. 启动 nginx..."
|
||||||
patch_version
|
|
||||||
|
|
||||||
echo -e "======================3. 启动nginx========================\n"
|
|
||||||
nginx -s reload 2>/dev/null || nginx -c /etc/nginx/nginx.conf
|
nginx -s reload 2>/dev/null || nginx -c /etc/nginx/nginx.conf
|
||||||
echo -e "nginx启动成功...\n"
|
|
||||||
|
|
||||||
reload_update
|
log_with_style "INFO" "⚙️ 3. 启动 pm2 服务...\n"
|
||||||
reload_pm2
|
reload_pm2
|
||||||
|
|
||||||
if [[ $AutoStartBot == true ]]; then
|
if [[ $AutoStartBot == true ]]; then
|
||||||
echo -e "======================5. 启动bot========================\n"
|
log_with_style "INFO" "🤖 4. 启动 bot..."
|
||||||
nohup ql bot >$dir_log/bot.log 2>&1 &
|
nohup ql bot >$dir_log/bot.log 2>&1 &
|
||||||
echo -e "bot后台启动中...\n"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $EnableExtraShell == true ]]; then
|
if [[ $EnableExtraShell == true ]]; then
|
||||||
echo -e "====================6. 执行自定义脚本========================\n"
|
log_with_style "INFO" "🛠️ 5. 执行自定义脚本..."
|
||||||
nohup ql extra >$dir_log/extra.log 2>&1 &
|
nohup ql extra >$dir_log/extra.log 2>&1 &
|
||||||
echo -e "自定义脚本后台执行中...\n"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pm2 startup
|
pm2 startup
|
||||||
pm2 save
|
pm2 save
|
||||||
|
|
||||||
echo -e "############################################################\n"
|
log_with_style "SUCCESS" "🎉 容器启动成功!"
|
||||||
echo -e "启动完成..."
|
|
||||||
echo -e "############################################################\n"
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user