Skip to content

Commit cedde46

Browse files
committed
update: http router update, some modify
1 parent 9d81537 commit cedde46

File tree

8 files changed

+405
-356
lines changed

8 files changed

+405
-356
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: inhere
5+
* Date: 2018/3/19
6+
* Time: 上午11:32
7+
*/
8+
9+
namespace Swoft\Http\Server\Bootstrap\Listener;
10+
11+
use Swoft\App;
12+
use Swoft\Bean\Annotation\ServerListener;
13+
use Swoft\Bootstrap\Listeners\Interfaces\StartInterface;
14+
use Swoft\Bootstrap\SwooleEvent;
15+
use Swoole\Server;
16+
17+
/**
18+
* Class MasterStartListener
19+
* @package Swoft\Http\Server\Bootstrap\Listener
20+
* @ServerListener(event=SwooleEvent::ON_START)
21+
*/
22+
class MasterStartListener implements StartInterface
23+
{
24+
public function onStart(Server $server)
25+
{
26+
\output()->writeln(
27+
'Server has been started. ' .
28+
"(master PID: <cyan>{$server->master_pid}</cyan>, manager PID: <cyan>{$server->manager_pid}</cyan>)"
29+
);
30+
31+
// output a message before start
32+
if (!App::$server->isDaemonize()) {
33+
\output()->writeln('You can use <info>CTRL + C</info> to stop run.');
34+
}
35+
}
36+
}

src/Command/ServerCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ public function start()
6060

6161
// 信息面板
6262
$lines = [
63-
' Information Panel ',
63+
' Server Information ',
6464
'********************************************************************',
65-
"* HTTP | host: <note>$httpHost</note>, port: <note>$httpPort</note>, mode: <note>$httpMode</note>, type: <note>$httpType</note>, Worker: <note>$workerNum</note>",
66-
"* TCP | host: <note>$tcpHost</note>, port: <note>$tcpPort</note>, type: <note>$tcpType</note>, Worker: <note>$workerNum</note> ($tcpEnable)",
65+
"* HTTP | host: <note>$httpHost</note>, port: <note>$httpPort</note>, type: <note>$httpType</note>, worker: <note>$workerNum</note>, mode: <note>$httpMode</note>",
66+
"* TCP | host: <note>$tcpHost</note>, port: <note>$tcpPort</note>, type: <note>$tcpType</note>, worker: <note>$workerNum</note> ($tcpEnable)",
6767
'********************************************************************',
6868
];
6969

src/Event/Listeners/ApplicationLoaderListener.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Swoft\Http\Server\Bean\Collector\ControllerCollector;
1010

1111
/**
12-
* the listener of applicatioin loader
12+
* the listener of application loader
1313
*
1414
* @Listener(AppEvent::APPLICATION_LOADER)
1515
* @uses ApplicationLoaderListener
@@ -22,6 +22,8 @@ class ApplicationLoaderListener implements EventHandlerInterface
2222
{
2323
/**
2424
* @param \Swoft\Event\EventInterface $event
25+
* @throws \LogicException
26+
* @throws \InvalidArgumentException
2527
*/
2628
public function handle(EventInterface $event)
2729
{
@@ -31,5 +33,4 @@ public function handle(EventInterface $event)
3133
$requestMapping = ControllerCollector::getCollector();
3234
$httpRouter->registerRoutes($requestMapping);
3335
}
34-
35-
}
36+
}

src/Http/HttpServer.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,21 +72,6 @@ protected function registerRpcEvent()
7272
$this->registerSwooleEvents($this->listen, $swooleRpcPortEvents);
7373
}
7474

75-
public function onStart(\Swoole\Server $server)
76-
{
77-
parent::onStart($server);
78-
79-
\output()->writeln(
80-
'Server has been started. ' .
81-
"(master PID: <info>{$server->master_pid}</info>, manager PID: <info>{$server->manager_pid}</info>)"
82-
);
83-
84-
// output a message before start
85-
if (!$this->isDaemonize()) {
86-
\output()->writeln("Press <info>Ctrl-C</info> to quit.\n");
87-
}
88-
}
89-
9075
/**
9176
* onRequest event callback
9277
* Each request will create an coroutine

0 commit comments

Comments
 (0)