illuminate各个包版本升级到10.x,删除docker.conf文件,删除console脚
本,重写各个脚本
This commit is contained in:
parent
68f42f3955
commit
9fbff7ccb0
@ -30,9 +30,7 @@
|
|||||||
|composer|调起容器中的`composer`命令的shell脚本|用法与主机中的compose完全一致,`./composer $args...`|
|
|composer|调起容器中的`composer`命令的shell脚本|用法与主机中的compose完全一致,`./composer $args...`|
|
||||||
|server|服务控制脚本|`./server`可以查看用法|
|
|server|服务控制脚本|`./server`可以查看用法|
|
||||||
|php|调起容器中的`php`命令的shell脚本|用法与主机中的php一致,但注意执行`./php start.php start`命令时不要加-d参数|
|
|php|调起容器中的`php`命令的shell脚本|用法与主机中的php一致,但注意执行`./php start.php start`命令时不要加-d参数|
|
||||||
|console|简化的`php webman`命令|执行`./console build`命令可以直接把项目打包成bin文件,其它用法与webman/console命令行插件一致|
|
|
||||||
|docker-compose.yml|运行容器的编排文件||
|
|docker-compose.yml|运行容器的编排文件||
|
||||||
|docker.conf|定义运行服务的容器名称和使用的镜像版本|注意container_name不要与系统中其他服务的容器重名|
|
|
||||||
|php.ini|映射到容器中的php.ini配置文件|容器中已经安装的扩展都有单独的配置文件,这里不会有体现|
|
|php.ini|映射到容器中的php.ini配置文件|容器中已经安装的扩展都有单独的配置文件,这里不会有体现|
|
||||||
|
|
||||||
## 服务端口
|
## 服务端口
|
||||||
|
21
composer
21
composer
@ -1,22 +1,3 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -e
|
docker compose run --rm webman-jsonrpc composer $@
|
||||||
|
|
||||||
source docker.conf
|
|
||||||
export WORKERMAN_CONTAINER_NAME=$container_name
|
|
||||||
export WORKERMAN_IMAGE_VERSION=$image_version
|
|
||||||
|
|
||||||
# 判断容器是否存在
|
|
||||||
if [ ! "$(docker ps -a -q -f name=$WORKERMAN_CONTAINER_NAME)" ]; then
|
|
||||||
# 调用init脚本
|
|
||||||
./init
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 判断容器是否在运行
|
|
||||||
if [ ! "$(docker inspect -f {{.State.Running}} $WORKERMAN_CONTAINER_NAME)" = "true" ]; then
|
|
||||||
# 启动容器
|
|
||||||
docker start $WORKERMAN_CONTAINER_NAME
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 进入容器并执行composer命令
|
|
||||||
docker exec -it $WORKERMAN_CONTAINER_NAME bash -c "composer $*"
|
|
@ -28,11 +28,11 @@
|
|||||||
"workerman/webman-framework": "^1.5.0",
|
"workerman/webman-framework": "^1.5.0",
|
||||||
"monolog/monolog": "^2.0",
|
"monolog/monolog": "^2.0",
|
||||||
"vlucas/phpdotenv": "^5.5",
|
"vlucas/phpdotenv": "^5.5",
|
||||||
"illuminate/database": "^8.83",
|
"illuminate/database": "^10.0",
|
||||||
"illuminate/pagination": "^8.83",
|
"illuminate/pagination": "^10.0",
|
||||||
"illuminate/events": "^8.83",
|
"illuminate/events": "^10.0",
|
||||||
"symfony/var-dumper": "^5.4",
|
"symfony/var-dumper": "^6.0",
|
||||||
"illuminate/redis": "^8.83",
|
"illuminate/redis": "^10.0",
|
||||||
"wandoubaba/res": "^1.0",
|
"wandoubaba/res": "^1.0",
|
||||||
"webman/console": "^1.2"
|
"webman/console": "^1.2"
|
||||||
},
|
},
|
||||||
|
894
composer.lock
generated
894
composer.lock
generated
File diff suppressed because it is too large
Load Diff
19
console
19
console
@ -1,19 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# 读取docker.conf文件
|
|
||||||
source docker.conf
|
|
||||||
|
|
||||||
# 设置系统环境变量
|
|
||||||
export WORKERMAN_CONTAINER_NAME=$container_name
|
|
||||||
export WORKERMAN_IMAGE_VERSION=$image_version
|
|
||||||
|
|
||||||
# 判断WORKERMAN_CONTAINER_NAME的docker容器是否存在,如果存在,删除它
|
|
||||||
if docker ps -a --format '{{.Names}}' | grep -q "^$WORKERMAN_CONTAINER_NAME$"; then
|
|
||||||
docker rm -f $WORKERMAN_CONTAINER_NAME
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $1 == "build" ]]; then
|
|
||||||
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
|
|
@ -2,8 +2,8 @@ version: "3.1"
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
webman-jsonrpc:
|
webman-jsonrpc:
|
||||||
image: wandoubaba517/workerman:${WORKERMAN_IMAGE_VERSION}
|
image: wandoubaba517/workerman:8.1
|
||||||
container_name: ${WORKERMAN_CONTAINER_NAME}
|
container_name: webman-jsonrpc
|
||||||
network_mode: host
|
network_mode: host
|
||||||
restart: always
|
restart: always
|
||||||
volumes:
|
volumes:
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
container_name=webman-jsonrpc
|
|
||||||
image_version=8.1
|
|
@ -17,7 +17,7 @@ generate_env_example() {
|
|||||||
key=$(echo "$line" | cut -d= -f1)
|
key=$(echo "$line" | cut -d= -f1)
|
||||||
value=$(echo "$line" | cut -d= -f2-)
|
value=$(echo "$line" | cut -d= -f2-)
|
||||||
# 如果键名包含指定字符串,将值清空写入.env.example文件
|
# 如果键名包含指定字符串,将值清空写入.env.example文件
|
||||||
if [[ $key == *KEY || $key == *PASSWORD || $key == *SECRET || $key == *PASS || $key == *TOKEN || $key == *ID ]]; then
|
if [[ $key == *KEY || $key == *PASSWORD* || $key == *SECRET* || $key == *PASS || $key == *TOKEN || $key == *ID ]]; then
|
||||||
echo "$key=" >> .env.example
|
echo "$key=" >> .env.example
|
||||||
# 否则,清除首尾空格后原样写入.env.example文件
|
# 否则,清除首尾空格后原样写入.env.example文件
|
||||||
else
|
else
|
||||||
|
31
init
31
init
@ -1,31 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
source docker.conf
|
|
||||||
export WORKERMAN_CONTAINER_NAME=$container_name
|
|
||||||
export WORKERMAN_IMAGE_VERSION=$image_version
|
|
||||||
|
|
||||||
# 判断.env文件是否存在
|
|
||||||
if [ ! -f .env ]; then
|
|
||||||
# 如果.env.example文件存在,则通过cp命令生成.env文件
|
|
||||||
if [ -f .env.example ]; then
|
|
||||||
cp .env.example .env
|
|
||||||
echo ".env file created from .env.example"
|
|
||||||
else
|
|
||||||
echo "Error: .env file does not exist and .env.example file also does not exist"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 判断容器是否存在
|
|
||||||
if [ "$(docker ps -a -q -f name=$WORKERMAN_CONTAINER_NAME)" ]; then
|
|
||||||
echo "Container $WORKERMAN_CONTAINER_NAME already exists. Please delete it before installing. Or user $(tput bold)./server <action>$(tput sgr0) to control it."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 启动容器
|
|
||||||
docker compose -f docker-compose.yml up -d
|
|
||||||
|
|
||||||
# 进入容器并执行composer install
|
|
||||||
docker exec -it $WORKERMAN_CONTAINER_NAME bash -c "composer install"
|
|
21
php
21
php
@ -1,22 +1,3 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -e
|
docker compose run --rm webman-jsonrpc php "$@"
|
||||||
|
|
||||||
source docker.conf
|
|
||||||
export WORKERMAN_CONTAINER_NAME=$container_name
|
|
||||||
export WORKERMAN_IMAGE_VERSION=$image_version
|
|
||||||
|
|
||||||
# 判断容器是否存在
|
|
||||||
if [ ! "$(docker ps -a -q -f name=$WORKERMAN_CONTAINER_NAME)" ]; then
|
|
||||||
# 调用init脚本
|
|
||||||
./init
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 判断容器是否在运行
|
|
||||||
if [ ! "$(docker inspect -f {{.State.Running}} $WORKERMAN_CONTAINER_NAME)" = "true" ]; then
|
|
||||||
# 启动容器
|
|
||||||
docker start $WORKERMAN_CONTAINER_NAME
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 进入容器并执行php命令
|
|
||||||
docker exec -it $WORKERMAN_CONTAINER_NAME bash -c "php $*"
|
|
||||||
|
35
server
35
server
@ -7,39 +7,38 @@ if [ -z "$1" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
source docker.conf
|
container_name="webman-jsonrpc"
|
||||||
export WORKERMAN_CONTAINER_NAME=$container_name
|
|
||||||
export WORKERMAN_IMAGE_VERSION=$image_version
|
|
||||||
|
|
||||||
if [ "$1" = "stop" ]; then
|
if [ "$1" = "stop" ]; then
|
||||||
if [ "$(docker inspect -f {{.State.Running}} $WORKERMAN_CONTAINER_NAME 2>/dev/null)" = "true" ]; then
|
if [ "$(docker inspect -f {{.State.Running}} $container_name 2>/dev/null)" = "true" ]; then
|
||||||
docker stop $WORKERMAN_CONTAINER_NAME
|
docker stop $container_name
|
||||||
else
|
else
|
||||||
echo "Container $WORKERMAN_CONTAINER_NAME is not running."
|
echo "Container $container_name is not running."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# 判断容器是否存在
|
# 判断容器是否存在
|
||||||
if [ ! "$(docker ps -a -q -f name=$WORKERMAN_CONTAINER_NAME)" ]; then
|
# if [ ! "$(docker ps -a -q -f name=$container_name)" ]; then
|
||||||
# 调用init脚本
|
# # 调用init脚本
|
||||||
./init
|
# ./init
|
||||||
fi
|
# fi
|
||||||
# 判断容器是否在运行
|
# 判断容器是否在运行
|
||||||
if [ ! "$(docker inspect -f {{.State.Running}} $WORKERMAN_CONTAINER_NAME 2>/dev/null)" = "true" ]; then
|
if [ ! "$(docker inspect -f {{.State.Running}} $container_name 2>/dev/null)" = "true" ]; then
|
||||||
# 启动容器
|
# 启动容器
|
||||||
docker start $WORKERMAN_CONTAINER_NAME
|
docker start $container_name
|
||||||
fi
|
fi
|
||||||
if [ "$1" = "logs" ]; then
|
if [ "$1" = "logs" ]; then
|
||||||
docker logs -f $WORKERMAN_CONTAINER_NAME
|
docker logs -f $container_name
|
||||||
elif [ "$1" = "start" ]; then
|
elif [ "$1" = "start" ]; then
|
||||||
docker exec -itd $WORKERMAN_CONTAINER_NAME bash -c "php start.php start"
|
# docker exec -itd $container_name bash -c "php start.php start"
|
||||||
|
:
|
||||||
elif [ "$1" = "restart" ]; then
|
elif [ "$1" = "restart" ]; then
|
||||||
docker exec -itd $WORKERMAN_CONTAINER_NAME bash -c "php start.php restart"
|
docker restart $container_name
|
||||||
elif [ "$1" = "status" ]; then
|
elif [ "$1" = "status" ]; then
|
||||||
docker exec -it $WORKERMAN_CONTAINER_NAME bash -c "php start.php status"
|
docker exec -it $container_name bash -c "php start.php status"
|
||||||
elif [ "$1" = "reload" ]; then
|
elif [ "$1" = "reload" ]; then
|
||||||
docker exec -it $WORKERMAN_CONTAINER_NAME bash -c "php start.php reload"
|
docker exec -it $container_name bash -c "php start.php reload"
|
||||||
elif [ "$1" = "connections" ]; then
|
elif [ "$1" = "connections" ]; then
|
||||||
docker exec -it $WORKERMAN_CONTAINER_NAME bash -c "php start.php connections"
|
docker exec -it $container_name bash -c "php start.php connections"
|
||||||
else
|
else
|
||||||
echo "Invalid command"
|
echo "Invalid command"
|
||||||
echo "Usage: $0 [start|stop|logs|restart|status|reload|connections]"
|
echo "Usage: $0 [start|stop|logs|restart|status|reload|connections]"
|
||||||
|
16
webman
16
webman
@ -36,8 +36,20 @@ foreach (config('plugin', []) as $firm => $projects) {
|
|||||||
if (!is_array($project)) {
|
if (!is_array($project)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
foreach ($project['command'] ?? [] as $command) {
|
foreach ($project['command'] ?? [] as $class_name) {
|
||||||
$cli->add(Container::get($command));
|
$reflection = new \ReflectionClass($class_name);
|
||||||
|
if ($reflection->isAbstract()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$properties = $reflection->getStaticProperties();
|
||||||
|
$name = $properties['defaultName'];
|
||||||
|
if (!$name) {
|
||||||
|
throw new RuntimeException("Command {$class_name} has no defaultName");
|
||||||
|
}
|
||||||
|
$description = $properties['defaultDescription'] ?? '';
|
||||||
|
$command = Container::get($class_name);
|
||||||
|
$command->setName($name)->setDescription($description);
|
||||||
|
$cli->add($command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user