a.Swoft-cli
1.下载
wget https://github.com/swoft-cloud/swoft-cli/releases/download/{VERSION}/swoftcli.phar
注意:你需要替换 {VERSION} 部分为最新版本。
wget https://github.com/swoft-cloud/swoft-cli/releases/download/v0.2.0/swoftcli.phar
2.测试
命令:
php swoftcli.phar -V
结果:
Command line tool application for quick use swoft (Version: 0.1.6)
/ / ______ / _/ / / / / / /
_ | /| / / __ / // / / / / / / /
__/ / |/ |/ / // / / / / // // /
//|/|/_// _/ _///
PHP: 7.2.30, Swoft: 2.0.8, Swoole: 4.5.0
3.文件转移到bin目录
命令:
mv swoftcli.phar /usr/local/bin/swoftcli
测试报错
swoftcli -V
-bash: /usr/local/bin/swoftcli: Permission denied
修改权限
命令:
chmod a+x /usr/local/bin/swoftcli
再次测试
swoftcli -V
?? Command line tool application for quick use swoft (Version: 0.1.6)
/ / ______ / _/ / / / / / /
_ | /| / / __ / // / / / / / / /
__/ / |/ |/ / // / / / / // // /
//|/|/_// _/ _///
PHP: 7.2.30, Swoft: 2.0.8, Swoole: 4.5.0
b. 热重启
命令:
swoftcli run -c http:start
结果:
Work Information
current pid 2592
current dir /root/Swoft
php binFile /usr/l**/bin/php
target path /root//Swoft
watch dirs app, config
entry file /root//bin/swoft
execute cmd /usr/l*******Swoft/bin/swoft http:start
Watched Directories
/root//Swoft/app
/root/*/Swoft/config
2020/05/05-07:04:47 [SWOFTCLI] Start swoft server
2020/05/05-15:04:47 [INFO] SwoftSwoftApplication:setSystemAlias(417) Project path: @base=/root/myproject/Swoft
2020/05/05-15:04:47 [INFO] SwoftSwoftApplication:setSystemAlias(418) Set alias @app=@base/app
2020/05/05-15:04:47 [INFO] SwoftSwoftApplication:setSystemAlias(419) Set alias @config=@base/config
2020/05/05-15:04:47 [INFO] SwoftSwoftApplication:setSystemAlias(420) Set alias @runtime=@base/runtime
2020/05/05-15:04:47 [INFO] SwoftProcessorEnvProcessor:handle(60) Env file(/root/myproject/Swoft/.env) is loaded
2020/05/05-15:04:48 [INFO] SwoftProcessorAnnotationProcessor:handle(45) Annotations is scanned(autoloader 36, annotation 472, parser 93)
2020/05/05-15:04:48 [INFO] SwoftProcessorBeanProcessor:handle(53) Bean is initialized(singleton 330, prototype 79, definition 50)
2020/05/05-15:04:48 [INFO] SwoftProcessorBeanProcessor:handle(57) Config path is /root/myproject/Swoft/config
2020/05/05-15:04:48 [INFO] SwoftProcessorBeanProcessor:handle(62) Config env is not setting
2020/05/05-15:04:48 [INFO] SwoftProcessorEventProcessor:handle(35) Event manager initialized(66 listener, 4 subscriber)
2020/05/05-15:04:48 [INFO] SwoftWebSocketServerListenerAppInitCompleteListener:handle(44) WebSocket server route registered(module 3, message command 14)
2020/05/05-15:04:48 [INFO] SwoftTcpServerListenerAppInitCompleteListener:handle(45) Tcp server route registered(routes 4)
2020/05/05-15:04:48 [INFO] SwoftErrorListenerAppInitCompleteListener:handle(34) Error manager init completed(4 type, 5 handler, 5 exception)
2020/05/05-15:04:48 [INFO] SwoftProcessorConsoleProcessor:handle(36) Console command route registered (group 14, command 44)
/ / _____ / / / / /__ ___ _ ___ _ _____ / / | | / _
_ | |/|/ / _ / / __/ / // __/ _ `/ ‘ / -) |/|/ / _ / __/ ‘/ / __// // /
//|,/_// _/ // // _,////__/|,/__// //_ /()/
SERVER INFORMATION(v2.0.9)
- HTTP | Listen: 0.0.0.0:9502, Mode: Process, Worker: 6, Task worker: 12
HTTP Server Start Success!
2020/05/05-15:04:48 [INFO] SwoftServerServer:startSwoole(491) SwooleRuntime::enableCoroutine
2020/05/05-15:04:48 [INFO] SwoftListenerBeforeStartListener:handle(27) Server extra info: pidFile @runtime/swoft.pid
2020/05/05-15:04:48 [INFO] SwoftListenerBeforeStartListener:handle(28) Registered swoole events:
start, shutdown, managerStart, managerStop, workerStart, workerStop, workerError, request, task, finish
Server start success (Master PID: 2594, Manager PID: 2600)
文件改变,自动重启