48 lines
1.4 KiB
Bash
Executable File
48 lines
1.4 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
|
|
|
|
container_name="webman-jsonrpc"
|
|
|
|
if [ "$1" = "stop" ]; then
|
|
if [ "$(docker inspect -f {{.State.Running}} $container_name 2>/dev/null)" = "true" ]; then
|
|
docker stop $container_name
|
|
else
|
|
echo "Container $container_name is not running."
|
|
fi
|
|
else
|
|
# 判断容器是否存在
|
|
# if [ ! "$(docker ps -a -q -f name=$container_name)" ]; then
|
|
# # 调用init脚本
|
|
# ./init
|
|
# fi
|
|
# 判断容器是否在运行
|
|
if [ ! "$(docker inspect -f {{.State.Running}} $container_name 2>/dev/null)" = "true" ]; then
|
|
# 启动容器
|
|
docker start $container_name
|
|
fi
|
|
if [ "$1" = "logs" ]; then
|
|
docker logs -f $container_name
|
|
elif [ "$1" = "start" ]; then
|
|
# docker exec -itd $container_name bash -c "php start.php start"
|
|
:
|
|
elif [ "$1" = "restart" ]; then
|
|
docker restart $container_name
|
|
elif [ "$1" = "status" ]; then
|
|
docker exec -it $container_name bash -c "php start.php status"
|
|
elif [ "$1" = "reload" ]; then
|
|
docker exec -it $container_name bash -c "php start.php reload"
|
|
elif [ "$1" = "connections" ]; then
|
|
docker exec -it $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
|