start, console
This commit is contained in:
parent
05e5fde379
commit
1b92be2fd1
@ -12,5 +12,8 @@ if docker ps -a --format '{{.Names}}' | grep -q "^$WORKERMAN_CONTAINER_NAME$"; t
|
|||||||
docker rm -f $WORKERMAN_CONTAINER_NAME
|
docker rm -f $WORKERMAN_CONTAINER_NAME
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ $1 == "build" ]]; then
|
||||||
docker compose run --rm $WORKERMAN_CONTAINER_NAME php webman build:bin $image_version && cp .env build/
|
docker compose run --rm $WORKERMAN_CONTAINER_NAME php webman build:bin $image_version && cp .env build/
|
||||||
|
else
|
||||||
|
docker compose run --rm $WORKERMAN_CONTAINER_NAME php webman "$@"
|
||||||
|
fi
|
53
start
53
start
@ -7,16 +7,55 @@ source docker.conf
|
|||||||
export WORKERMAN_CONTAINER_NAME=$container_name
|
export WORKERMAN_CONTAINER_NAME=$container_name
|
||||||
export WORKERMAN_IMAGE_VERSION=$image_version
|
export WORKERMAN_IMAGE_VERSION=$image_version
|
||||||
|
|
||||||
# 判断WORKERMAN_CONTAINER_NAME的docker容器是否存在,如果存在,删除它
|
# 检查docker-compose.yml文件是否存在
|
||||||
if docker ps -a --format '{{.Names}}' | grep -q "^$WORKERMAN_CONTAINER_NAME$"; then
|
if [ ! -f "docker-compose.yml" ]; then
|
||||||
docker rm -f $WORKERMAN_CONTAINER_NAME
|
echo "Error: docker-compose.yml file not found"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
docker compose run --rm $WORKERMAN_CONTAINER_NAME composer install
|
# 定义帮助函数
|
||||||
|
show_help() {
|
||||||
|
echo "Usage: ./start [COMMAND]"
|
||||||
|
echo ""
|
||||||
|
echo "Commands:"
|
||||||
|
echo " run once"
|
||||||
|
echo " start run once"
|
||||||
|
echo " -d run in daemon mode"
|
||||||
|
echo " status service status(daemon mode only)"
|
||||||
|
echo " reload reload files(daemon mode only)"
|
||||||
|
echo " restart restart service(daemon mode only)"
|
||||||
|
echo " stop stop service and container"
|
||||||
|
echo " help show this help message"
|
||||||
|
}
|
||||||
|
|
||||||
# 根据参数执行docker compose up命令
|
# 定义安装依赖的函数
|
||||||
if [[ $1 == "-d" ]]; then
|
install_dependencies() {
|
||||||
|
# 执行一次composer install
|
||||||
|
docker compose run --rm $WORKERMAN_CONTAINER_NAME composer install
|
||||||
|
}
|
||||||
|
|
||||||
|
# 根据参数执行不同的命令
|
||||||
|
if [[ $# -eq 0 || $1 == "start" ]]; then
|
||||||
|
install_dependencies
|
||||||
|
docker compose run --rm $WORKERMAN_CONTAINER_NAME php start.php start
|
||||||
|
elif [[ $1 == "-d" ]]; then
|
||||||
|
install_dependencies
|
||||||
docker compose up -d
|
docker compose up -d
|
||||||
|
elif [[ $1 == "help" ]]; then
|
||||||
|
show_help
|
||||||
else
|
else
|
||||||
docker compose up
|
# 判断WORKERMAN_CONTAINER_NAME的docker容器是否存在,如果不存在,直接退出
|
||||||
|
if ! docker ps -a --format '{{.Names}}' | grep -q "^$WORKERMAN_CONTAINER_NAME$"; then
|
||||||
|
echo "container not exist."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if ! docker ps --format '{{.Names}}' | grep -q "^$WORKERMAN_CONTAINER_NAME$"; then
|
||||||
|
echo "container is not running."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
# 执行php start命令
|
||||||
|
docker exec -it $WORKERMAN_CONTAINER_NAME php start.php "$@"
|
||||||
|
if [[ $1 == "stop" ]]; then
|
||||||
|
docker stop $WORKERMAN_CONTAINER_NAME
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user