From 384e437440b16e9f9a928e451e7cb7f01ab342ba Mon Sep 17 00:00:00 2001 From: Cuishibing <643237029@qq.com> Date: Sun, 26 Apr 2026 13:00:22 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E6=94=AF=E6=8C=81=E7=AB=AF=E5=8F=A3=E3=80=81?= =?UTF-8?q?=E5=AD=98=E5=82=A8=E7=9B=AE=E5=BD=95=E3=80=81=E5=AF=86=E7=A0=81?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- start.sh | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100755 start.sh diff --git a/start.sh b/start.sh new file mode 100755 index 0000000..c0fb3a9 --- /dev/null +++ b/start.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +PORT=3000 +STORAGE_DIR="" +ADMIN_PASSWORD="" + +show_help() { + echo "Usage: $0 [options]" + echo "" + echo "Options:" + echo " -p, --port PORT 服务端口 (默认: 3000)" + echo " -s, --storage DIR 存储目录 (默认: ./storage)" + echo " -w, --password PASS 管理员密码" + echo " -h, --help 显示帮助" +} + +while [[ $# -gt 0 ]]; do + case $1 in + -p|--port) + PORT="$2" + shift 2 + ;; + -s|--storage) + STORAGE_DIR="$2" + shift 2 + ;; + -w|--password) + ADMIN_PASSWORD="$2" + shift 2 + ;; + -h|--help) + show_help + exit 0 + ;; + *) + echo "未知参数: $1" + show_help + exit 1 + ;; + esac +done + +# 构建命令 +CMD="npm start" +ENV_VARS="PORT=$PORT" + +if [ -n "$STORAGE_DIR" ]; then + ENV_VARS="$ENV_VARS STORAGE_DIR=$STORAGE_DIR" +fi + +if [ -n "$ADMIN_PASSWORD" ]; then + ENV_VARS="$ENV_VARS ADMIN_PASSWORD=$ADMIN_PASSWORD" +fi + +echo "启动服务..." +echo " 端口: $PORT" +if [ -n "$STORAGE_DIR" ]; then + echo " 存储: $STORAGE_DIR" +fi +echo " 命令: $ENV_VARS $CMD" + +nohup sh -c "$ENV_VARS $CMD" > nohup.out 2>&1 & + +echo "服务已启动 (PID: $!)" +echo "查看日志: tail -f nohup.out" \ No newline at end of file