pipeline-app/start.sh

38 lines
1.2 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
set -e
WORKDIR="$(cd "$(dirname "$0")" && pwd)"
cd "$WORKDIR"
# 加载本机敏感环境变量(如短信密钥),不存在则跳过(该文件不入库)
[ -f .smssend ] && source .smssend
# 运行模式all(默认HTTP+poller) / web(仅HTTP无poller) / worker(仅poller分布式worker节点)
# 多 worker 本机/跨机测试bash start.sh worker <id>id=1,2,3...,端口 9090+idpid 独立)
MODE="${1:-all}"
case "$MODE" in
web) PORT=9090; PIDFILE="pipeline-web.pid"; PIPELINE_MODE=web ;;
worker)
WID="${2:-1}"
PORT=$((9090 + WID))
PIDFILE="pipeline-worker-${WID}.pid"
PIPELINE_MODE=worker ;;
all) PORT=9090; PIDFILE="pipeline.pid"; PIPELINE_MODE=all ;;
*) echo "用法: $0 [web|worker <id>|all]"; exit 1 ;;
esac
export PIPELINE_MODE
if [ -f "$PIDFILE" ]; then
pid=$(cat "$PIDFILE")
if kill -0 "$pid" 2>/dev/null; then
echo "Already running (PID $pid)"
exit 0
fi
rm -f "$PIDFILE"
fi
echo "Starting pipeline-app ($MODE mode) on port $PORT..."
export PATH="$WORKDIR/bin:$PATH"
$WORKDIR/py3/bin/python $WORKDIR/app/pipeline_app.py -p $PORT -w $WORKDIR >> $WORKDIR/logs/pipeline.log 2>&1 &
echo $! > "$PIDFILE"
echo "Started PID $(cat $PIDFILE)"