Skip to content

Commit 36e9b35

Browse files
committed
some update
1 parent 2bd0a4b commit 36e9b35

File tree

3 files changed

+48
-36
lines changed

3 files changed

+48
-36
lines changed

docs/show-ascii-font.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# show cli font
2+
3+
```php
4+
5+
$name = '404';
6+
ArtFont::create()->show($name, ArtFont::INTERNAL_GROUP,[
7+
'type' => $this->input->getBoolOpt('italic') ? 'italic' : '',
8+
'style' => $this->input->getOpt('style'),
9+
]);
10+
11+
```

src/Utils/CliUtil.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,6 @@ public static function getNullDevice()
3939
return 'NUL';
4040
}
4141

42-
/**
43-
* run a command in background
44-
* @param string $cmd
45-
*/
46-
public static function execInBackground($cmd)
47-
{
48-
if (Helper::isWindows()) {
49-
pclose(popen('start /B ' . $cmd, 'r'));
50-
} else {
51-
exec($cmd . ' > /dev/null &');
52-
}
53-
}
54-
5542
/**
5643
* @param string $command
5744
* @param null|string $logfile

src/Utils/ProcessUtil.php

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,19 @@ public static function daemonRun(\Closure $beforeQuit = null)
5151
return $pid;
5252
}
5353

54+
/**
55+
* run a command in background
56+
* @param string $cmd
57+
*/
58+
public static function runInBackground($cmd)
59+
{
60+
if (Helper::isWindows()) {
61+
pclose(popen('start /B ' . $cmd, 'r'));
62+
} else {
63+
exec($cmd . ' > /dev/null &');
64+
}
65+
}
66+
5467
/**
5568
* fork multi child processes.
5669
* @param int $number
@@ -309,7 +322,7 @@ public static function sendSignal($pid, $signal, $timeout = 0)
309322
}
310323

311324
/**
312-
* @param $pid
325+
* @param int $pid
313326
* @return bool
314327
*/
315328
public static function isRunning($pid)
@@ -339,6 +352,28 @@ public static function getPid()
339352
return getmypid();// or use posix_getpid()
340353
}
341354

355+
/**
356+
* get Pid from File
357+
* @param string $file
358+
* @param bool $checkLive
359+
* @return int
360+
*/
361+
public static function getPidByFile($file, $checkLive = false)
362+
{
363+
if ($file && file_exists($file)) {
364+
$pid = (int)file_get_contents($file);
365+
366+
// check live
367+
if ($checkLive && self::isRunning($pid)) {
368+
return $pid;
369+
}
370+
371+
unlink($file);
372+
}
373+
374+
return 0;
375+
}
376+
342377
/**
343378
* Get unix user of current process.
344379
* @return array
@@ -462,25 +497,4 @@ public static function changeScriptOwner($user, $group = '')
462497
}
463498
}
464499

465-
/**
466-
* get Pid from File
467-
* @param string $file
468-
* @param bool $checkLive
469-
* @return int
470-
*/
471-
public static function getPidFromFile($file, $checkLive = false)
472-
{
473-
if ($file && file_exists($file)) {
474-
$pid = (int)file_get_contents($file);
475-
476-
// check live
477-
if ($checkLive && self::isRunning($pid)) {
478-
return $pid;
479-
}
480-
481-
unlink($file);
482-
}
483-
484-
return 0;
485-
}
486-
}
500+
}

0 commit comments

Comments
 (0)