批量启动springboot
#!/bin/bash
# 检查容器是否已经启动
check_container() {
sudo docker ps | grep "$1" >/dev/null
if [ $? -ne 0 ]; then
echo "$1 container is not running. Starting $1..."
sudo docker start "$1"
else
echo "$1 container is already running."
fi
}
# 检查MySQL容器
check_container "mysql"
# 检查Redis容器
check_container "redis"
# 检查Nacos容器
check_container "nacos-standalone"
# 检查容器是否成功启动
check_success() {
sudo docker ps | grep "$1" >/dev/null
if [ $? -ne 0 ]; then
echo "Failed to start $1. Please check the logs or start it manually."
exit 1
else
echo "$1 is running."
fi
}
# 检查MySQL是否成功启动
check_success "mysql"
# 检查Redis是否成功启动
check_success "redis"
# 检查Nacos是否成功启动
check_success "nacos-standalone"
# 检查目录是否存在
check_directory() {
if [ ! -d "$1" ]; then
echo "Directory $1 does not exist."
exit 1
fi
}
check_directory "api-boss"
check_directory "api-driver"
check_directory "api-passenger"
check_directory "serice-map"
check_directory "service-driver-user"
check_directory "service-passenger-user"
check_directory "service-order"
check_directory "service-pay"
check_directory "service-price"
check_directory "service-sse-push"
check_directory "service-verificationcode"
# 启动应用并重定向日志
start_application() {
cd "$1"
nohup mvn spring-boot:run > "$1.log" 2>&1 &
cd ..
}
start_application "api-boss"
start_application "api-driver"
start_application "api-passenger"
start_application "serice-map"
start_application "service-driver-user"
start_application "service-passenger-user"
start_application "service-order"
start_application "service-pay"
start_application "service-price"
start_application "service-sse-push"
start_application "service-verficationcode"
# 批量杀死java进程
# jps | awk '{print $1}' | xargs kill -9
批量启动Vuejs
#!/bin/bash
# 检查目录是否存在
check_directory() {
if [ ! -d "$1" ]; then
echo "Directory $1 does not exist."
exit 1
fi
}
# 前端:乘客端源码
frontend_passenger_dir="乘客端源码20230221"
check_directory "$frontend_passenger_dir"
cd "$frontend_passenger_dir"
nohup yarn >/dev/null 2>&1 &
nohup yarn dev:h5 >/dev/null 2>&1 &
cd ../
# 前端:司机端源码
frontend_driver_dir="司机端源码-20230209-新版本"
check_directory "$frontend_driver_dir"
cd "$frontend_driver_dir"
nohup yarn >/dev/null 2>&1 &
nohup yarn dev:h5 >/dev/null 2>&1 &
cd ../..