illuminate各个包版本升级到10.x,删除docker.conf文件,删除console脚

本,重写各个脚本
This commit is contained in:
wandoubaba517 2023-12-23 12:31:40 +08:00
parent 68f42f3955
commit 9fbff7ccb0
12 changed files with 536 additions and 521 deletions

View File

@ -30,9 +30,7 @@
|composer|调起容器中的`composer`命令的shell脚本|用法与主机中的compose完全一致`./composer $args...`|
|server|服务控制脚本|`./server`可以查看用法|
|php|调起容器中的`php`命令的shell脚本|用法与主机中的php一致但注意执行`./php start.php start`命令时不要加-d参数|
|console|简化的`php webman`命令|执行`./console build`命令可以直接把项目打包成bin文件其它用法与webman/console命令行插件一致|
|docker-compose.yml|运行容器的编排文件||
|docker.conf|定义运行服务的容器名称和使用的镜像版本|注意container_name不要与系统中其他服务的容器重名|
|php.ini|映射到容器中的php.ini配置文件|容器中已经安装的扩展都有单独的配置文件,这里不会有体现|
## 服务端口

View File

@ -1,22 +1,3 @@
#!/bin/bash
set -e
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 $*"
docker compose run --rm webman-jsonrpc composer $@

View File

@ -28,11 +28,11 @@
"workerman/webman-framework": "^1.5.0",
"monolog/monolog": "^2.0",
"vlucas/phpdotenv": "^5.5",
"illuminate/database": "^8.83",
"illuminate/pagination": "^8.83",
"illuminate/events": "^8.83",
"symfony/var-dumper": "^5.4",
"illuminate/redis": "^8.83",
"illuminate/database": "^10.0",
"illuminate/pagination": "^10.0",
"illuminate/events": "^10.0",
"symfony/var-dumper": "^6.0",
"illuminate/redis": "^10.0",
"wandoubaba/res": "^1.0",
"webman/console": "^1.2"
},

894
composer.lock generated

File diff suppressed because it is too large Load Diff

19
console
View File

@ -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

View File

@ -2,8 +2,8 @@ version: "3.1"
services:
webman-jsonrpc:
image: wandoubaba517/workerman:${WORKERMAN_IMAGE_VERSION}
container_name: ${WORKERMAN_CONTAINER_NAME}
image: wandoubaba517/workerman:8.1
container_name: webman-jsonrpc
network_mode: host
restart: always
volumes:

View File

@ -1,2 +0,0 @@
container_name=webman-jsonrpc
image_version=8.1

View File

@ -17,7 +17,7 @@ generate_env_example() {
key=$(echo "$line" | cut -d= -f1)
value=$(echo "$line" | cut -d= -f2-)
# 如果键名包含指定字符串,将值清空写入.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
# 否则,清除首尾空格后原样写入.env.example文件
else

31
init
View File

@ -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
View File

@ -1,22 +1,3 @@
#!/bin/bash
set -e
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 $*"
docker compose run --rm webman-jsonrpc php "$@"

35
server
View File

@ -7,39 +7,38 @@ if [ -z "$1" ]; then
exit 1
fi
source docker.conf
export WORKERMAN_CONTAINER_NAME=$container_name
export WORKERMAN_IMAGE_VERSION=$image_version
container_name="webman-jsonrpc"
if [ "$1" = "stop" ]; then
if [ "$(docker inspect -f {{.State.Running}} $WORKERMAN_CONTAINER_NAME 2>/dev/null)" = "true" ]; then
docker stop $WORKERMAN_CONTAINER_NAME
if [ "$(docker inspect -f {{.State.Running}} $container_name 2>/dev/null)" = "true" ]; then
docker stop $container_name
else
echo "Container $WORKERMAN_CONTAINER_NAME is not running."
echo "Container $container_name is not running."
fi
else
# 判断容器是否存在
if [ ! "$(docker ps -a -q -f name=$WORKERMAN_CONTAINER_NAME)" ]; then
# 调用init脚本
./init
fi
# if [ ! "$(docker ps -a -q -f name=$container_name)" ]; then
# # 调用init脚本
# ./init
# 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
if [ "$1" = "logs" ]; then
docker logs -f $WORKERMAN_CONTAINER_NAME
docker logs -f $container_name
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
docker exec -itd $WORKERMAN_CONTAINER_NAME bash -c "php start.php restart"
docker restart $container_name
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
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
docker exec -it $WORKERMAN_CONTAINER_NAME bash -c "php start.php connections"
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]"

16
webman
View File

@ -36,8 +36,20 @@ foreach (config('plugin', []) as $firm => $projects) {
if (!is_array($project)) {
continue;
}
foreach ($project['command'] ?? [] as $command) {
$cli->add(Container::get($command));
foreach ($project['command'] ?? [] as $class_name) {
$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);
}
}
}