UnisKB/installer/start-all.sh

37 lines
1.1 KiB
Bash
Raw Normal View History

2025-04-18 06:10:16 +00:00
#!/bin/bash
2025-04-18 09:02:59 +00:00
set -e
2025-07-16 01:26:34 +00:00
if [ -f "/opt/maxkb/PG_VERSION" ]; then
2025-07-01 08:01:49 +00:00
# 如果是v1版本一键安装的的目录则退出
echo -e "\033[1;31mFATAL ERROR: Upgrade from v1 to v2 is not supported.\033[0m"
echo -e "\033[1;31mThe process will exit.\033[0m"
2025-07-01 08:01:49 +00:00
exit 1
fi
2025-04-18 06:10:16 +00:00
if [ "$MAXKB_DB_HOST" = "127.0.0.1" ]; then
echo -e "\033[1;32mPostgreSQL starting...\033[0m"
2025-04-21 07:39:29 +00:00
/usr/bin/start-postgres.sh &
2025-07-01 08:01:49 +00:00
postgres_pid=$!
sleep 5
wait-for-it 127.0.0.1:5432 --timeout=120 --strict -- echo -e "\033[1;32mPostgreSQL started.\033[0m"
2025-04-18 06:10:16 +00:00
fi
if [ "$MAXKB_REDIS_HOST" = "127.0.0.1" ]; then
echo -e "\033[1;32mRedis starting...\033[0m"
2025-04-21 07:39:29 +00:00
/usr/bin/start-redis.sh &
2025-07-01 08:01:49 +00:00
redis_pid=$!
2025-04-21 07:39:29 +00:00
sleep 5
wait-for-it 127.0.0.1:6379 --timeout=60 --strict -- echo -e "\033[1;32mRedis started.\033[0m"
2025-04-18 06:10:16 +00:00
fi
echo -e "\033[1;32mMaxKB starting...\033[0m"
2025-07-01 08:01:49 +00:00
/usr/bin/start-maxkb.sh &
maxkb_pid=$!
sleep 10
wait-for-it 127.0.0.1:8080 --timeout=60 --strict -- echo -e "\033[1;32mMaxKB started.\033[0m"
2025-07-01 08:01:49 +00:00
wait -n
echo -e "\033[1;31mSystem is shutting down.\033[0m"
2025-07-01 08:01:49 +00:00
kill $postgres_pid $redis_pid $maxkb_pid 2>/dev/null
wait