docker-webman-jsonrpc/server
2023-11-11 13:23:35 +08:00

49 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
set -e
if [ -z "$1" ]; then
echo "Usage: $0 [start|stop|logs|restart|status|reload|connections]"
exit 1
fi
source docker.conf
export WORKERMAN_CONTAINER_NAME=$container_name
export WORKERMAN_IMAGE_VERSION=$image_version
if [ "$1" = "stop" ]; then
if [ "$(docker inspect -f {{.State.Running}} $WORKERMAN_CONTAINER_NAME 2>/dev/null)" = "true" ]; then
docker stop $WORKERMAN_CONTAINER_NAME
else
echo "Container $WORKERMAN_CONTAINER_NAME is not running."
fi
else
# 判断容器是否存在
if [ ! "$(docker ps -a -q -f name=$WORKERMAN_CONTAINER_NAME)" ]; then
# 调用init脚本
./init
fi
# 判断容器是否在运行
if [ ! "$(docker inspect -f {{.State.Running}} $WORKERMAN_CONTAINER_NAME 2>/dev/null)" = "true" ]; then
# 启动容器
docker start $WORKERMAN_CONTAINER_NAME
fi
if [ "$1" = "logs" ]; then
docker logs -f $WORKERMAN_CONTAINER_NAME
elif [ "$1" = "start" ]; then
:
elif [ "$1" = "restart" ]; then
docker restart $WORKERMAN_CONTAINER_NAME
elif [ "$1" = "status" ]; then
docker exec -it $WORKERMAN_CONTAINER_NAME bash -c "php start.php status"
elif [ "$1" = "reload" ]; then
docker exec -it $WORKERMAN_CONTAINER_NAME bash -c "php start.php reload"
elif [ "$1" = "connections" ]; then
docker exec -it $WORKERMAN_CONTAINER_NAME bash -c "php start.php connections"
else
echo "Invalid command"
echo "Usage: $0 [start|stop|logs|restart|status|reload|connections]"
exit 1
fi
fi