@@ -12,7 +12,7 @@ class HttpServerCommand extends Command
12
12
*
13
13
* @var string
14
14
*/
15
- protected $ signature = 'swoole:http {action : start|stop|restart|reload} ' ;
15
+ protected $ signature = 'swoole:http {action : start|stop|restart|reload|infos } ' ;
16
16
17
17
/**
18
18
* The console command description.
@@ -152,23 +152,49 @@ protected function reload()
152
152
153
153
$ isRunning = $ this ->killProcess ($ pid , SIGUSR1 );
154
154
155
- if (!$ isRunning ) {
155
+ if (! $ isRunning ) {
156
156
$ this ->error ('> failure ' );
157
157
exit (1 );
158
158
}
159
159
160
160
$ this ->info ('> success ' );
161
161
}
162
162
163
+
164
+ /**
165
+ * Display PHP and Swoole misc info.
166
+ */
167
+ protected function infos ()
168
+ {
169
+ $ this ->showInfos ();
170
+ }
171
+
172
+ /**
173
+ * Display PHP and Swoole miscs infos.
174
+ */
175
+ protected function showInfos ()
176
+ {
177
+ $ pid = $ this ->getPid ();
178
+ $ isRunning = $ this ->isRunning ($ pid );
179
+
180
+ $ this ->table (['Name ' , 'Value ' ], [
181
+ ['PHP Version ' , 'Version ' => phpversion ()],
182
+ ['Swoole Version ' , 'Version ' => swoole_version ()],
183
+ ['Laravel Version ' , $ this ->getApplication ()->getVersion ()],
184
+ ['Server Status ' , $ isRunning ? 'Online ' : 'Offline ' ],
185
+ ['PID ' , $ isRunning ? $ pid : 'None ' ],
186
+ ]);
187
+ }
188
+
163
189
/**
164
190
* Initialize command action.
165
191
*/
166
192
protected function initAction ()
167
193
{
168
194
$ this ->action = $ this ->argument ('action ' );
169
195
170
- if (! in_array ($ this ->action , ['start ' , 'stop ' , 'restart ' , 'reload ' ])) {
171
- $ this ->error ("Invalid argument ' {$ this ->action }'. Expected 'start', 'stop', 'restart' or 'reload '. " );
196
+ if (! in_array ($ this ->action , ['start ' , 'stop ' , 'restart ' , 'reload ' , ' infos ' ])) {
197
+ $ this ->error ("Invalid argument ' {$ this ->action }'. Expected 'start', 'stop', 'restart', 'reload' or 'infos '. " );
172
198
exit (1 );
173
199
}
174
200
}
@@ -181,13 +207,13 @@ protected function initAction()
181
207
*/
182
208
protected function isRunning ($ pid )
183
209
{
184
- if (!$ pid ) {
210
+ if (! $ pid ) {
185
211
return false ;
186
212
}
187
213
188
214
Process::kill ($ pid , 0 );
189
215
190
- return !swoole_errno ();
216
+ return ! swoole_errno ();
191
217
}
192
218
193
219
/**
@@ -206,7 +232,7 @@ protected function killProcess($pid, $sig, $wait = 0)
206
232
$ start = time ();
207
233
208
234
do {
209
- if (!$ this ->isRunning ($ pid )) {
235
+ if (! $ this ->isRunning ($ pid )) {
210
236
break ;
211
237
}
212
238
@@ -234,7 +260,7 @@ protected function getPid()
234
260
if (file_exists ($ path )) {
235
261
$ pid = (int ) file_get_contents ($ path );
236
262
237
- if (!$ pid ) {
263
+ if (! $ pid ) {
238
264
$ this ->removePidFile ();
239
265
} else {
240
266
$ this ->pid = $ pid ;
0 commit comments