env
This commit is contained in:
parent
67a3eda692
commit
85ded3c5d1
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,3 +3,4 @@
|
||||
.buildpath
|
||||
composer.lock
|
||||
vendor/
|
||||
.env
|
||||
|
@ -18,7 +18,7 @@ require_once __DIR__ . '/Clients/StatisticClient.php';
|
||||
require_once __DIR__.'/Protocols/JsonNL.php';
|
||||
|
||||
// 开启的端口
|
||||
$worker = new Worker('JsonNL://0.0.0.0:2015');
|
||||
$worker = new Worker('JsonNL://0.0.0.0:' . $_ENV['RPC_PORT'] ?: '2015');
|
||||
// 启动多少服务进程
|
||||
$worker->count = 16;
|
||||
// worker名称,php start.php status 时展示使用
|
||||
@ -27,7 +27,7 @@ $worker->name = 'JsonRpc';
|
||||
|
||||
$worker->onMessage = function($connection, $data)
|
||||
{
|
||||
$statistic_address = 'udp://127.0.0.1:55656';
|
||||
$statistic_address = 'udp://127.0.0.1:' . $_ENV['STATISTIC_WORKER_PORT'] ?: '55656';
|
||||
// 判断数据是否正确
|
||||
if(empty($data['class']) || empty($data['method']) || !isset($data['param_array']))
|
||||
{
|
||||
@ -78,7 +78,6 @@ $worker->onMessage = function($connection, $data)
|
||||
|
||||
};
|
||||
|
||||
|
||||
// 如果不是在根目录启动,则运行runAll方法
|
||||
if(!defined('GLOBAL_START'))
|
||||
{
|
||||
|
@ -20,18 +20,18 @@ use Bootstrap\StatisticWorker;
|
||||
use \Workerman\Worker;
|
||||
use \Workerman\WebServer;
|
||||
// StatisticProvider
|
||||
$statistic_provider = new StatisticProvider("Text://0.0.0.0:55858");
|
||||
$statistic_provider = new StatisticProvider("Text://0.0.0.0:" . $_ENV['STATISTIC_PROVIDER_PORT'] ?: '55858');
|
||||
$statistic_provider->name = 'StatisticProvider';
|
||||
// StatisticWorker
|
||||
$statistic_worker = new StatisticWorker("Statistic://0.0.0.0:55656");
|
||||
$statistic_worker = new StatisticWorker("Statistic://0.0.0.0:" . $_ENV['STATISTIC_WORKER_PORT'] ?: '55656');
|
||||
$statistic_worker->transport = 'udp';
|
||||
$statistic_worker->name = 'StatisticWorker';
|
||||
// WebServer
|
||||
$web = new WebServer("http://0.0.0.0:55757");
|
||||
$web = new WebServer("http://0.0.0.0:" . $_ENV['STATISTIC_WEB_PORT'] ?: '55757');
|
||||
$web->name = 'StatisticWeb';
|
||||
$web->addRoot('www.your_domain.com', __DIR__.'/Web');
|
||||
$web->addRoot($_ENV['DOMAIN'] ?: 'localhost', __DIR__.'/Web');
|
||||
// recv udp broadcast
|
||||
$udp_finder = new Worker("Text://0.0.0.0:55858");
|
||||
$udp_finder = new Worker("Text://0.0.0.0:" . $_ENV['STATISTIC_PROVIDER_PORT'] ?: '55858');
|
||||
$udp_finder->name = 'StatisticFinder';
|
||||
$udp_finder->transport = 'udp';
|
||||
$udp_finder->onMessage = function ($connection, $data)
|
||||
|
@ -5,6 +5,7 @@
|
||||
"homepage": "http://www.workerman.net",
|
||||
"license" : "MIT",
|
||||
"require": {
|
||||
"workerman/statistics" : ">=1.0.0"
|
||||
"workerman/statistics" : ">=1.0.0",
|
||||
"vlucas/phpdotenv": "^5.5"
|
||||
}
|
||||
}
|
||||
|
45
start
45
start
@ -2,40 +2,17 @@
|
||||
service_name="workerman-jsonrpc"
|
||||
compose_file="docker-compose-dev.yml"
|
||||
|
||||
if [ $# -eq 0 ] || [ $1 == "start" ]
|
||||
then
|
||||
docker rm -f $service_name
|
||||
docker-compose -f $compose_file up -d
|
||||
docker exec $service_name php start.php start
|
||||
else
|
||||
docker rm -f $service_name
|
||||
docker-compose -f $compose_file up -d
|
||||
docker exec $service_name php start.php "$@"
|
||||
fi#!/bin/bash
|
||||
service_name="workerman-jsonrpc"
|
||||
compose_file="docker-compose-dev.yml"
|
||||
if ! docker inspect -f '{{.State.Running}}' $service_name >/dev/null 2>&1; then
|
||||
if ! docker-compose -f $compose_file up -d >/dev/null 2>&1; then
|
||||
if ! docker compose -f $compose_file up -d >/dev/null 2>&1; then
|
||||
echo "Failed to start the container using docker-compose or docker compose."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $# -eq 0 ] || [ $1 == "start" ]
|
||||
then
|
||||
docker rm -f $service_name
|
||||
if docker-compose -f $compose_file up -d; then
|
||||
docker exec $service_name php start.php start
|
||||
else
|
||||
if docker compose -f $compose_file up -d; then
|
||||
docker exec $service_name php start.php start
|
||||
else
|
||||
echo "Failed to start the container using docker-compose or docker compose."
|
||||
fi
|
||||
fi
|
||||
if [ $# -eq 0 ] || [ $1 == "start" ]; then
|
||||
docker exec $service_name php start.php restart
|
||||
else
|
||||
docker rm -f $service_name
|
||||
if docker-compose -f $compose_file up -d; then
|
||||
docker exec $service_name php start.php "$@"
|
||||
else
|
||||
if docker compose -f $compose_file up -d; then
|
||||
docker exec $service_name php start.php "$@"
|
||||
else
|
||||
echo "Failed to start the container using docker-compose or docker compose."
|
||||
fi
|
||||
fi
|
||||
docker exec $service_name php start.php "$@"
|
||||
fi
|
@ -23,10 +23,15 @@ define('GLOBAL_START', 1);
|
||||
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
// 加载.env文件
|
||||
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
|
||||
$dotenv->load();
|
||||
|
||||
// 加载所有Applications/*/start.php,以便启动所有服务
|
||||
foreach(glob(__DIR__.'/Applications/*/start*.php') as $start_file)
|
||||
{
|
||||
require_once $start_file;
|
||||
}
|
||||
|
||||
// 运行所有服务
|
||||
Worker::runAll();
|
||||
|
Loading…
Reference in New Issue
Block a user