diff --git a/.gitignore b/.gitignore index 0307853..975f476 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,3 @@ -/.idea -/.vscode -/vendor -*.log -.env -/tests/tmp -/tests/.phpunit.result.cache +!.gitignore +.idea +.vscode \ No newline at end of file diff --git a/.env.example b/api/.env.example similarity index 100% rename from .env.example rename to api/.env.example diff --git a/api/.gitignore b/api/.gitignore new file mode 100644 index 0000000..0307853 --- /dev/null +++ b/api/.gitignore @@ -0,0 +1,7 @@ +/.idea +/.vscode +/vendor +*.log +.env +/tests/tmp +/tests/.phpunit.result.cache diff --git a/LICENSE b/api/LICENSE similarity index 100% rename from LICENSE rename to api/LICENSE diff --git a/README.md b/api/README.md similarity index 100% rename from README.md rename to api/README.md diff --git a/app/biz/ResCode.php b/api/app/biz/ResCode.php similarity index 100% rename from app/biz/ResCode.php rename to api/app/biz/ResCode.php diff --git a/app/controller/IndexController.php b/api/app/controller/IndexController.php similarity index 100% rename from app/controller/IndexController.php rename to api/app/controller/IndexController.php diff --git a/api/app/controller/TestController.php b/api/app/controller/TestController.php new file mode 100644 index 0000000..14e281a --- /dev/null +++ b/api/app/controller/TestController.php @@ -0,0 +1,26 @@ +info(__CLASS__ . DIRECTORY_SEPARATOR . __FUNCTION__, $_SERVER); + $logs = Db::connection('mongolog')->collection('request')->get(); + // foreach ($logs as $log) { + // $log->delete(); + // } + // $logs->delete(); + $res->setData($logs); + return json($res); + } + +} diff --git a/app/exception/Handler.php b/api/app/exception/Handler.php similarity index 100% rename from app/exception/Handler.php rename to api/app/exception/Handler.php diff --git a/app/functions.php b/api/app/functions.php similarity index 100% rename from app/functions.php rename to api/app/functions.php diff --git a/app/global.php b/api/app/global.php similarity index 100% rename from app/global.php rename to api/app/global.php diff --git a/app/jsonrpc/Demo.php b/api/app/jsonrpc/Demo.php similarity index 100% rename from app/jsonrpc/Demo.php rename to api/app/jsonrpc/Demo.php diff --git a/app/jsonrpc/User.php b/api/app/jsonrpc/User.php similarity index 100% rename from app/jsonrpc/User.php rename to api/app/jsonrpc/User.php diff --git a/api/app/middleware/AccessControl.php b/api/app/middleware/AccessControl.php new file mode 100644 index 0000000..a256f0c --- /dev/null +++ b/api/app/middleware/AccessControl.php @@ -0,0 +1,23 @@ +method() == 'OPTIONS' ? response('') : $handler($request); + $response->withHeaders([ + 'Access-Control-Allow-Credentials' => 'true', + 'Access-Control-Allow-Origin' => $request->header('Origin', '*'), + 'Access-Control-Allow-Methods' => '*', + 'Access-Control-Allow-Headers' => '*,ACCESSTOKEN', + ]); + + return $response; + } + +} diff --git a/api/app/middleware/RequestLog.php b/api/app/middleware/RequestLog.php new file mode 100644 index 0000000..784edfb --- /dev/null +++ b/api/app/middleware/RequestLog.php @@ -0,0 +1,68 @@ +controller); + $action = strtolower($request->action); + $path = "{$controller}\\{$action}"; // 完整的控制器\方法字符串 + // 白名单方法的请求不拦截 + if (in_array($path, $this->actionWhiteList)) { + return $next($request); + } + // 只拦截指定控制器的请求 + if (!in_array($controller, $this->controllerScope)) { + return $next($request); + } + $info = [ + 'session_id' => $request->sessionId(), + 'protocol_version' => $request->protocolVersion(), + 'method' => $request->method(), + 'ip' => $request->getRemoteIp(), + 'real_ip' => $request->getRealIp(), + 'host' => $request->host(), + 'path' => $request->path(), + 'uri' => $request->uri(), + 'url' => $request->url(), + 'full_url' => $request->fullUrl(), + 'query_string' => $request->queryString(), + 'get_params' => $request->get(), + 'post_params' => $request->post(), + 'local_ip' => $request->getLocalIp(), + 'local_port' => $request->getLocalPort(), + 'is_ajax' => $request->isAjax(), + 'is_pjax' => $request->isPjax(), + 'expects_json' => $request->expectsJson(), + 'accept_json' => $request->acceptJson(), + ]; + Log::channel('request')->info('', $info); + return $next($request); + } + +} diff --git a/app/middleware/StaticFile.php b/api/app/middleware/StaticFile.php similarity index 100% rename from app/middleware/StaticFile.php rename to api/app/middleware/StaticFile.php diff --git a/app/model/Test.php b/api/app/model/Test.php similarity index 100% rename from app/model/Test.php rename to api/app/model/Test.php diff --git a/app/view/index/view.html b/api/app/view/index/view.html similarity index 100% rename from app/view/index/view.html rename to api/app/view/index/view.html diff --git a/build/.gitignore b/api/build/.gitignore similarity index 100% rename from build/.gitignore rename to api/build/.gitignore diff --git a/composer b/api/composer similarity index 100% rename from composer rename to api/composer diff --git a/composer.json b/api/composer.json similarity index 93% rename from composer.json rename to api/composer.json index 6e3d241..0f5e342 100644 --- a/composer.json +++ b/api/composer.json @@ -26,7 +26,7 @@ "require": { "php": ">=7.2", "workerman/webman-framework": "^1.5.0", - "monolog/monolog": "^2.0", + "monolog/monolog": "^3.0", "vlucas/phpdotenv": "^5.5", "illuminate/database": "^10.0", "illuminate/pagination": "^10.0", @@ -34,7 +34,8 @@ "symfony/var-dumper": "^6.0", "illuminate/redis": "^10.0", "wandoubaba/res": "^1.0", - "webman/console": "^1.2" + "webman/console": "^1.2", + "mongodb/laravel-mongodb": "^4.1" }, "suggest": { "ext-event": "For better performance. " diff --git a/composer.lock b/api/composer.lock similarity index 90% rename from composer.lock rename to api/composer.lock index 4f1ddae..11e7983 100644 --- a/composer.lock +++ b/api/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "40e690c07a34d05e3eb1432d45aa0852", + "content-hash": "b60184ef23f8e71843aa7695eed31518", "packages": [ { "name": "brick/math", @@ -933,6 +933,65 @@ }, "time": "2023-12-25T01:11:56+00:00" }, + { + "name": "jean85/pretty-package-versions", + "version": "2.0.5", + "source": { + "type": "git", + "url": "https://github.com/Jean85/pretty-package-versions.git", + "reference": "ae547e455a3d8babd07b96966b17d7fd21d9c6af" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/ae547e455a3d8babd07b96966b17d7fd21d9c6af", + "reference": "ae547e455a3d8babd07b96966b17d7fd21d9c6af", + "shasum": "" + }, + "require": { + "composer-runtime-api": "^2.0.0", + "php": "^7.1|^8.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.17", + "jean85/composer-provided-replaced-stub-package": "^1.0", + "phpstan/phpstan": "^0.12.66", + "phpunit/phpunit": "^7.5|^8.5|^9.4", + "vimeo/psalm": "^4.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Jean85\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Alessandro Lai", + "email": "alessandro.lai85@gmail.com" + } + ], + "description": "A library to get pretty versions strings of installed dependencies", + "keywords": [ + "composer", + "package", + "release", + "versions" + ], + "support": { + "issues": "https://github.com/Jean85/pretty-package-versions/issues", + "source": "https://github.com/Jean85/pretty-package-versions/tree/2.0.5" + }, + "time": "2021-10-08T21:21:46+00:00" + }, { "name": "laravel/serializable-closure", "version": "v1.3.3", @@ -994,43 +1053,210 @@ "time": "2023-11-08T14:08:06+00:00" }, { - "name": "monolog/monolog", - "version": "2.9.2", + "name": "mongodb/laravel-mongodb", + "version": "4.1.1", "source": { "type": "git", - "url": "https://github.com/Seldaek/monolog.git", - "reference": "437cb3628f4cf6042cc10ae97fc2b8472e48ca1f" + "url": "https://github.com/mongodb/laravel-mongodb.git", + "reference": "5c16d0ec3aee352987ae9f8fe70914357d23badc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Seldaek/monolog/zipball/437cb3628f4cf6042cc10ae97fc2b8472e48ca1f", - "reference": "437cb3628f4cf6042cc10ae97fc2b8472e48ca1f", + "url": "https://api.github.com/repos/mongodb/laravel-mongodb/zipball/5c16d0ec3aee352987ae9f8fe70914357d23badc", + "reference": "5c16d0ec3aee352987ae9f8fe70914357d23badc", "shasum": "" }, "require": { - "php": ">=7.2", - "psr/log": "^1.0.1 || ^2.0 || ^3.0" + "ext-mongodb": "^1.15", + "illuminate/container": "^10.0", + "illuminate/database": "^10.30", + "illuminate/events": "^10.0", + "illuminate/support": "^10.0", + "mongodb/mongodb": "^1.15", + "php": "^8.1" }, - "provide": { - "psr/log-implementation": "1.0.0 || 2.0.0 || 3.0.0" + "replace": { + "jenssegers/mongodb": "self.version" }, "require-dev": { - "aws/aws-sdk-php": "^2.4.9 || ^3.0", + "doctrine/coding-standard": "12.0.x-dev", + "mockery/mockery": "^1.4.4", + "orchestra/testbench": "^8.0", + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^10.3", + "spatie/laravel-query-builder": "^5.6" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "MongoDB\\Laravel\\MongoDBServiceProvider", + "MongoDB\\Laravel\\MongoDBQueueServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "MongoDB\\Laravel\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Andreas Braun", + "email": "andreas.braun@mongodb.com", + "role": "Leader" + }, + { + "name": "Jérôme Tamarelle", + "email": "jerome.tamarelle@mongodb.com", + "role": "Maintainer" + }, + { + "name": "Jeremy Mikola", + "email": "jmikola@gmail.com", + "role": "Maintainer" + }, + { + "name": "Jens Segers", + "homepage": "https://jenssegers.com", + "role": "Creator" + } + ], + "description": "A MongoDB based Eloquent model and Query builder for Laravel", + "homepage": "https://github.com/mongodb/laravel-mongodb", + "keywords": [ + "database", + "eloquent", + "laravel", + "model", + "mongo", + "mongodb" + ], + "support": { + "issues": "https://www.mongodb.com/support", + "security": "https://www.mongodb.com/security", + "source": "https://github.com/mongodb/laravel-mongodb/tree/4.1.1" + }, + "time": "2024-01-17T10:04:05+00:00" + }, + { + "name": "mongodb/mongodb", + "version": "1.17.0", + "source": { + "type": "git", + "url": "https://github.com/mongodb/mongo-php-library.git", + "reference": "9d9c917cf7ff275ed6bd63c596efeb6e49fd0e53" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mongodb/mongo-php-library/zipball/9d9c917cf7ff275ed6bd63c596efeb6e49fd0e53", + "reference": "9d9c917cf7ff275ed6bd63c596efeb6e49fd0e53", + "shasum": "" + }, + "require": { + "ext-hash": "*", + "ext-json": "*", + "ext-mongodb": "^1.17.0", + "jean85/pretty-package-versions": "^2.0.1", + "php": "^7.4 || ^8.0", + "psr/log": "^1.1.4|^2|^3", + "symfony/polyfill-php80": "^1.27", + "symfony/polyfill-php81": "^1.27" + }, + "require-dev": { + "doctrine/coding-standard": "^12.0", + "rector/rector": "^0.18", + "squizlabs/php_codesniffer": "^3.7", + "symfony/phpunit-bridge": "^5.2", + "vimeo/psalm": "^5.13" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.17.x-dev" + } + }, + "autoload": { + "files": [ + "src/functions.php" + ], + "psr-4": { + "MongoDB\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Andreas Braun", + "email": "andreas.braun@mongodb.com" + }, + { + "name": "Jeremy Mikola", + "email": "jmikola@gmail.com" + }, + { + "name": "Jérôme Tamarelle", + "email": "jerome.tamarelle@mongodb.com" + } + ], + "description": "MongoDB driver library", + "homepage": "https://jira.mongodb.org/browse/PHPLIB", + "keywords": [ + "database", + "driver", + "mongodb", + "persistence" + ], + "support": { + "issues": "https://github.com/mongodb/mongo-php-library/issues", + "source": "https://github.com/mongodb/mongo-php-library/tree/1.17.0" + }, + "time": "2023-11-15T09:21:50+00:00" + }, + { + "name": "monolog/monolog", + "version": "3.5.0", + "source": { + "type": "git", + "url": "https://github.com/Seldaek/monolog.git", + "reference": "c915e2634718dbc8a4a15c61b0e62e7a44e14448" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/c915e2634718dbc8a4a15c61b0e62e7a44e14448", + "reference": "c915e2634718dbc8a4a15c61b0e62e7a44e14448", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "psr/log": "^2.0 || ^3.0" + }, + "provide": { + "psr/log-implementation": "3.0.0" + }, + "require-dev": { + "aws/aws-sdk-php": "^3.0", "doctrine/couchdb": "~1.0@dev", "elasticsearch/elasticsearch": "^7 || ^8", "ext-json": "*", - "graylog2/gelf-php": "^1.4.2 || ^2@dev", - "guzzlehttp/guzzle": "^7.4", + "graylog2/gelf-php": "^1.4.2 || ^2.0", + "guzzlehttp/guzzle": "^7.4.5", "guzzlehttp/psr7": "^2.2", "mongodb/mongodb": "^1.8", "php-amqplib/php-amqplib": "~2.4 || ^3", - "phpspec/prophecy": "^1.15", - "phpstan/phpstan": "^0.12.91", - "phpunit/phpunit": "^8.5.14", - "predis/predis": "^1.1 || ^2.0", - "rollbar/rollbar": "^1.3 || ^2 || ^3", + "phpstan/phpstan": "^1.9", + "phpstan/phpstan-deprecation-rules": "^1.0", + "phpstan/phpstan-strict-rules": "^1.4", + "phpunit/phpunit": "^10.1", + "predis/predis": "^1.1 || ^2", "ruflin/elastica": "^7", - "swiftmailer/swiftmailer": "^5.3|^6.0", "symfony/mailer": "^5.4 || ^6", "symfony/mime": "^5.4 || ^6" }, @@ -1053,7 +1279,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "2.x-dev" + "dev-main": "3.x-dev" } }, "autoload": { @@ -1081,7 +1307,7 @@ ], "support": { "issues": "https://github.com/Seldaek/monolog/issues", - "source": "https://github.com/Seldaek/monolog/tree/2.9.2" + "source": "https://github.com/Seldaek/monolog/tree/3.5.0" }, "funding": [ { @@ -1093,7 +1319,7 @@ "type": "tidelift" } ], - "time": "2023-10-27T15:25:26+00:00" + "time": "2023-10-27T15:32:31+00:00" }, { "name": "nesbot/carbon", @@ -2231,6 +2457,82 @@ ], "time": "2023-01-26T09:26:14+00:00" }, + { + "name": "symfony/polyfill-php81", + "version": "v1.29.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php81.git", + "reference": "c565ad1e63f30e7477fc40738343c62b40bc672d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/c565ad1e63f30e7477fc40738343c62b40bc672d", + "reference": "c565ad1e63f30e7477fc40738343c62b40bc672d", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php81\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php81/tree/v1.29.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-01-29T20:11:03+00:00" + }, { "name": "symfony/service-contracts", "version": "v3.4.1", diff --git a/config/app.php b/api/config/app.php similarity index 100% rename from config/app.php rename to api/config/app.php diff --git a/config/autoload.php b/api/config/autoload.php similarity index 100% rename from config/autoload.php rename to api/config/autoload.php diff --git a/config/bootstrap.php b/api/config/bootstrap.php similarity index 100% rename from config/bootstrap.php rename to api/config/bootstrap.php diff --git a/config/container.php b/api/config/container.php similarity index 100% rename from config/container.php rename to api/config/container.php diff --git a/config/database.php b/api/config/database.php similarity index 72% rename from config/database.php rename to api/config/database.php index 29d4806..0e387f3 100644 --- a/config/database.php +++ b/api/config/database.php @@ -46,5 +46,18 @@ return [ 'schema' => env('PG_SCHEMA', 'public'), 'sslmode' => 'prefer', ], + 'mongolog' => [ + 'driver' => 'mongodb', + 'host' => env('MONGOLOG_HOST', '127.0.0.1'), + 'port' => env('MONGOLOG_PORT', 27017), + 'database' => env('MONGOLOG_DATABASE', 'log'), + 'username' => env('MONGOLOG_USERNAME', null), + 'password' => env('MONGOLOG_PASSWORD', null), + 'options' => [ + // here you can pass more settings to the Mongo Driver Manager + // see https://www.php.net/manual/en/mongodb-driver-manager.construct.php under "Uri Options" for a list of complete parameters that you can use + 'appname' => 'homestead' + ], + ], ] ]; diff --git a/config/dependence.php b/api/config/dependence.php similarity index 100% rename from config/dependence.php rename to api/config/dependence.php diff --git a/config/exception.php b/api/config/exception.php similarity index 100% rename from config/exception.php rename to api/config/exception.php diff --git a/config/jsonrpc.php b/api/config/jsonrpc.php similarity index 100% rename from config/jsonrpc.php rename to api/config/jsonrpc.php diff --git a/config/log.php b/api/config/log.php similarity index 61% rename from config/log.php rename to api/config/log.php index c4b2815..89446b1 100644 --- a/config/log.php +++ b/api/config/log.php @@ -1,4 +1,6 @@ Monolog\Handler\RotatingFileHandler::class, 'constructor' => [ runtime_path() . '/logs/webman.log', - 7, //$maxFiles - Monolog\Logger::DEBUG, + env('LOG_MAX_FIlES', 7), //$maxFiles + Monolog\Level::Debug, ], 'formatter' => [ 'class' => Monolog\Formatter\LineFormatter::class, 'constructor' => [null, 'Y-m-d H:i:s', true], ], + ], [ + 'class' => Monolog\Handler\MongoDBHandler::class, + 'constructor' => [ + new Client(env('MONGOLOG_URL', 'mongodb://localhost:27017')), + env('MONGOLOG_DATABASE', 'log'), + 'default', + Monolog\Level::Debug, + ], ] ], ], @@ -36,24 +46,32 @@ return [ 'constructor' => [ runtime_path() . '/logs/debug/debug.log', env('LOG_MAX_FILES_DEBUG') ?: env('LOG_MAX_FIlES') ?: 7, //$maxFiles - Monolog\Logger::DEBUG, + Monolog\Level::Debug, ], 'formatter' => [ 'class' => Monolog\Formatter\LineFormatter::class, 'constructor' => [null, 'Y-m-d H:i:s.u', true, true], ], + ], [ + 'class' => Monolog\Handler\MongoDBHandler::class, + 'constructor' => [ + new Client(env('MONGOLOG_URL', 'mongodb://localhost:27017')), + env('MONGOLOG_DATABASE', 'log'), + 'debug', + Monolog\Level::Debug, + ], ], [ // 把日志输出到控制台 'class' => Monolog\Handler\StreamHandler::class, 'constructor' => [ 'php://stdout', - Monolog\Logger::DEBUG, + Monolog\Level::Debug, ], 'formatter' => [ 'class' => Monolog\Formatter\LineFormatter::class, 'constructor' => [null, 'Y-m-d H:i:s.u', true, true], ], - ], + ] ], ], 'error' => [ @@ -63,18 +81,26 @@ return [ 'constructor' => [ runtime_path() . '/logs/error/error.log', env('LOG_MAX_FILES_ERROR') ?: env('LOG_MAX_FIlES') ?: 7, //$maxFiles - Monolog\Logger::DEBUG, + Monolog\Level::Debug, ], 'formatter' => [ 'class' => Monolog\Formatter\LineFormatter::class, 'constructor' => [null, 'Y-m-d H:i:s.u', true, true], ], + ], [ + 'class' => Monolog\Handler\MongoDBHandler::class, + 'constructor' => [ + new Client(env('MONGOLOG_URL', 'mongodb://localhost:27017')), + env('MONGOLOG_DATABASE', 'log'), + 'error', + Monolog\Level::Debug, + ], ], [ // 把日志输出到控制台 'class' => Monolog\Handler\StreamHandler::class, 'constructor' => [ 'php://stdout', - Monolog\Logger::DEBUG, + Monolog\Level::Debug, ], 'formatter' => [ 'class' => Monolog\Formatter\LineFormatter::class, @@ -83,5 +109,18 @@ return [ ], ], ], - + // 记录请求日志 + 'request' => [ + 'handlers' => [ + [ + 'class' => Monolog\Handler\MongoDBHandler::class, + 'constructor' => [ + new Client(env('MONGOLOG_URL', 'mongodb://localhost:27017')), + env('MONGOLOG_DATABASE', 'log'), + 'request', + Monolog\Level::Debug, + ], + ], + ], + ], ]; diff --git a/config/middleware.php b/api/config/middleware.php similarity index 64% rename from config/middleware.php rename to api/config/middleware.php index 8e964ed..4f4a5c9 100644 --- a/config/middleware.php +++ b/api/config/middleware.php @@ -12,4 +12,13 @@ * @license http://www.opensource.org/licenses/mit-license.php MIT License */ -return []; \ No newline at end of file +return [ + '' => [ + // 静态文件保护 + app\middleware\StaticFile::class, + // 跨域请求 + app\middleware\AccessControl::class, + // 记录请求日志 + app\middleware\RequestLog::class, + ], +]; \ No newline at end of file diff --git a/config/plugin/webman/console/app.php b/api/config/plugin/webman/console/app.php similarity index 100% rename from config/plugin/webman/console/app.php rename to api/config/plugin/webman/console/app.php diff --git a/config/process.php b/api/config/process.php similarity index 100% rename from config/process.php rename to api/config/process.php diff --git a/config/redis.php b/api/config/redis.php similarity index 100% rename from config/redis.php rename to api/config/redis.php diff --git a/config/route.php b/api/config/route.php similarity index 100% rename from config/route.php rename to api/config/route.php diff --git a/config/server.php b/api/config/server.php similarity index 100% rename from config/server.php rename to api/config/server.php diff --git a/config/session.php b/api/config/session.php similarity index 100% rename from config/session.php rename to api/config/session.php diff --git a/config/static.php b/api/config/static.php similarity index 100% rename from config/static.php rename to api/config/static.php diff --git a/config/translation.php b/api/config/translation.php similarity index 100% rename from config/translation.php rename to api/config/translation.php diff --git a/config/view.php b/api/config/view.php similarity index 100% rename from config/view.php rename to api/config/view.php diff --git a/api/docker-compose.yml b/api/docker-compose.yml new file mode 100644 index 0000000..6f4a49e --- /dev/null +++ b/api/docker-compose.yml @@ -0,0 +1,12 @@ +version: "3.1" + +services: + webman-jsonrpc: + image: wandoubaba517/workerman:8.1 + container_name: webman-jsonrpc + network_mode: host + volumes: + - ./:/app/service + - ./php.ini:/usr/local/etc/php/php.ini + working_dir: /app/service + stdin_open: true diff --git a/envexample b/api/envexample similarity index 100% rename from envexample rename to api/envexample diff --git a/jsonrpc/Client.php b/api/jsonrpc/Client.php similarity index 100% rename from jsonrpc/Client.php rename to api/jsonrpc/Client.php diff --git a/jsonrpc/Protocol.php b/api/jsonrpc/Protocol.php similarity index 100% rename from jsonrpc/Protocol.php rename to api/jsonrpc/Protocol.php diff --git a/jsonrpc/Server.php b/api/jsonrpc/Server.php similarity index 100% rename from jsonrpc/Server.php rename to api/jsonrpc/Server.php diff --git a/php b/api/php similarity index 100% rename from php rename to api/php diff --git a/php.ini b/api/php.ini similarity index 100% rename from php.ini rename to api/php.ini diff --git a/process/Monitor.php b/api/process/Monitor.php similarity index 100% rename from process/Monitor.php rename to api/process/Monitor.php diff --git a/public/404.html b/api/public/404.html similarity index 100% rename from public/404.html rename to api/public/404.html diff --git a/public/favicon.ico b/api/public/favicon.ico similarity index 100% rename from public/favicon.ico rename to api/public/favicon.ico diff --git a/runtime/.gitignore b/api/runtime/.gitignore similarity index 100% rename from runtime/.gitignore rename to api/runtime/.gitignore diff --git a/runtime/logs/.gitignore b/api/runtime/logs/.gitignore similarity index 100% rename from runtime/logs/.gitignore rename to api/runtime/logs/.gitignore diff --git a/runtime/views/.gitignore b/api/runtime/views/.gitignore similarity index 100% rename from runtime/views/.gitignore rename to api/runtime/views/.gitignore diff --git a/server b/api/server similarity index 97% rename from server rename to api/server index e96e3f3..401f014 100755 --- a/server +++ b/api/server @@ -7,7 +7,7 @@ if [ -z "$1" ]; then exit 1 fi -container_name="webman-jsonrpc" +container_name="webman-jsonrpc-api" if [ "$1" = "stop" ]; then if [ "$(docker inspect -f {{.State.Running}} $container_name 2>/dev/null)" = "true" ]; then diff --git a/start.php b/api/start.php similarity index 100% rename from start.php rename to api/start.php diff --git a/support/Request.php b/api/support/Request.php similarity index 100% rename from support/Request.php rename to api/support/Request.php diff --git a/support/Response.php b/api/support/Response.php similarity index 100% rename from support/Response.php rename to api/support/Response.php diff --git a/support/bootstrap.php b/api/support/bootstrap.php similarity index 100% rename from support/bootstrap.php rename to api/support/bootstrap.php diff --git a/support/helpers.php b/api/support/helpers.php similarity index 100% rename from support/helpers.php rename to api/support/helpers.php diff --git a/webman b/api/webman similarity index 100% rename from webman rename to api/webman diff --git a/windows.bat b/api/windows.bat similarity index 100% rename from windows.bat rename to api/windows.bat diff --git a/windows.php b/api/windows.php similarity index 100% rename from windows.php rename to api/windows.php diff --git a/docker-compose.yml b/docker-compose.yml index 452fd47..b035a96 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,13 +1,26 @@ version: "3.1" services: - webman-jsonrpc: + api: image: wandoubaba517/workerman:8.1 - container_name: webman-jsonrpc + container_name: webman-jsonrpc-api network_mode: host restart: always volumes: - - ./:/app/service - - ./php.ini:/usr/local/etc/php/php.ini + - ./api/:/app/service + - ./api/php.ini:/usr/local/etc/php/php.ini working_dir: /app/service stdin_open: true + depends_on: + - log + command: ['php', 'start.php', 'start'] + + log: + image: mongo:6.0 + container_name: webman-jsonrpc-log + restart: always + volumes: + - ./log/db:/data/db + - ./log/mongod.conf:/etc/mongod.conf + network_mode: host + command: ['mongod', '--config', '/etc/mongod.conf'] diff --git a/log/.gitignore b/log/.gitignore new file mode 100644 index 0000000..63c1ee0 --- /dev/null +++ b/log/.gitignore @@ -0,0 +1,2 @@ +!.gitignore +db/* \ No newline at end of file diff --git a/log/mongod.conf b/log/mongod.conf new file mode 100644 index 0000000..5bfd55d --- /dev/null +++ b/log/mongod.conf @@ -0,0 +1,40 @@ +# mongod.conf + +# for documentation of all options, see: +# http://docs.mongodb.org/manual/reference/configuration-options/ + +# Where and how to store data. +storage: + dbPath: /data/db +# engine: +# wiredTiger: + +# where to write logging data. +# systemLog: +# destination: file +# logAppend: true +# path: /var/log/mongodb/mongod.log + +# network interfaces +net: + port: 27019 + bindIp: 0.0.0.0 + + +# how the process runs +# processManagement: +# timeZoneInfo: /usr/share/zoneinfo + +#security: + +#operationProfiling: + +#replication: + +#sharding: + +## Enterprise-Only Options: + +#auditLog: + +#snmp: