Created
February 16, 2020 01:14
-
-
Save jesseschutt/734e4a43f5a10189e6ac2a5f696b839f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Console\Commands; | |
use Illuminate\Console\Command; | |
use Symfony\Component\Process\Process; | |
class MQTT extends Command | |
{ | |
protected $signature = 'mqtt:kill-process'; | |
protected $description = 'Stop the overseer mqtt node process'; | |
public function handle() | |
{ | |
$process = new Process(['pkill', '-f', 'mqtt-demo-process-node']); | |
$process->start(); | |
foreach ($process as $type => $data) { | |
if ($process::OUT === $type) { | |
echo "\nRead from stdout: ".$data; | |
} else { | |
echo "\nRead from stderr: ".$data; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment