代码拉取完成,页面将自动刷新
<?php
/*
* @Create By: Vscode
* @Author: falcon
* @Date: 2019-05-03 08:40:06
* @星爱后台
*/
use Workerman\Worker;
use application\depend\Regular;
use application\depend\Appresult;
require_once __DIR__ . '/Workerman/Autoloader.php';
require_once __DIR__ . '/config/errcode.php';
require_once __DIR__ . '/config/debug.php';
require_once __DIR__ . '/application/common/base.php';
define('APP_LOG_PATH_NEW', __DIR__ . '/runtime');
define('APP_START_ROOT_PATH', __DIR__); //根目录
define('MAX_REQUEST', 1000);// 最大请求量
// 创建一个Worker监听端口,使用http协议通讯
$http_worker = new Worker("http://0.0.0.0:" . WEB_SERVER_PORT);
//服务名称
$http_worker->name = "xingai-webserver";
// 启动4个进程对外提供服务
$http_worker->count = WEB_SERVER_PROCESS_NUM;
if (!is_dir(APP_LOG_PATH_NEW)) {
@mkdir(APP_LOG_PATH_NEW);
}
Worker::$logFile = APP_LOG_PATH_NEW . '/workerman.log';
Worker::$stdoutFile = APP_LOG_PATH_NEW . '/std_' . date("Y-m-d_H");
// 接收到浏览器发送的数据时回复hello world给浏览器
$http_worker->onMessage = function ($connection, $data) {
static $request_count = 0;
// 向浏览器发送hello world
if (isset($_SERVER['REQUEST_URI'])) {
$reqPath = $_SERVER['REQUEST_URI'];
if (Regular::checkPathInfo($reqPath)) {
$reqPath = rtrim($reqPath, "/");
switch ($reqPath) {
case "/phptest/kafka": //kafka 测试
$obj = new \application\controller\Kafka();
$msg = $obj->main();
break;
case "/delete/repeat":
$obj = new \application\controller\delrepeat();
$msg = $obj->run();
break;
case "/orderstatus/sync":
$obj = new \application\controller\OrderStatusSync();
$msg = $obj->main();
break;
case "/modify/ordersalesman":
$obj = new \application\controller\Fix();
$msg = $obj->main();
break;
default:
$msg = [
'oh' => 'zero kill[uo]'
];
break;
}
} else {
$msg = [
'hello' => 'org!'
];
}//
} else {
$msg = [
'aaa' => 'done',
];
}
if (is_object($msg)) {
$msg = (array)$msg;
if (!isset($msg['total']) || null === $msg['total']) {
unset($msg['total']);
}
}
$msg = json_encode($msg, JSON_UNESCAPED_UNICODE);
if (null == $msg) {
$result = new Appresult();
$result->result = ERR_DB_DATA_EMPTY;
$result->msg = "返回结果失败咯!";
$connection->send(json_encode($result, JSON_UNESCAPED_UNICODE));
} else {
$connection->send($msg);
}//end if
if (++$request_count >= MAX_REQUEST) {
Worker::stopAll();
}//end if
};
// require_once __DIR__ . '/timer.php';
Worker::runAll();
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。