This commit is contained in:
2021-03-29 12:12:23 +08:00
parent 3b186e94a2
commit bbe6e27a26
+6 -9
View File
@@ -32,8 +32,6 @@ class Shutdown extends Component
*/ */
public function init() public function init()
{ {
exec('ps -eo pid', $this->_pids);
$this->taskDirectory = storage(null, 'pid/task'); $this->taskDirectory = storage(null, 'pid/task');
$this->workerDirectory = storage(null, 'pid/worker'); $this->workerDirectory = storage(null, 'pid/worker');
$this->managerDirectory = storage(null, 'pid/manager'); $this->managerDirectory = storage(null, 'pid/manager');
@@ -99,12 +97,9 @@ class Shutdown extends Component
if (intval($content) < 1) { if (intval($content) < 1) {
return false; return false;
} }
exec('ps -eo pid', $this->_pids);
$id = Config::get('id', false, 'system'); var_dump($this->_pids);
if (in_array($content, $this->_pids)) {
$shell = 'ps -eo pid,state | grep \'%s\' | grep -v grep';
exec(sprintf($shell, $id . '[' . intval($content) . ']'), $output, $code);
if (empty($output)) {
return false; return false;
} }
return true; return true;
@@ -114,6 +109,7 @@ class Shutdown extends Component
/** /**
* @param string $path * @param string $path
* @return bool * @return bool
* @throws ConfigException
*/ */
public function directoryCheck(string $path): bool public function directoryCheck(string $path): bool
{ {
@@ -134,13 +130,14 @@ class Shutdown extends Component
/** /**
* @param string $value * @param string $value
* @throws ConfigException
*/ */
public function close(string $value) public function close(string $value)
{ {
$content = file_get_contents($value); $content = file_get_contents($value);
while ($this->pidIsExists($content)) { while ($this->pidIsExists($content)) {
exec('kill -15 ' . $content); // exec('kill -15 ' . $content);
sleep(1); sleep(1);
} }