Skip to content

Instantly share code, notes, and snippets.

@jesseschutt
Created February 16, 2020 01:14
Show Gist options
  • Save jesseschutt/734e4a43f5a10189e6ac2a5f696b839f to your computer and use it in GitHub Desktop.
Save jesseschutt/734e4a43f5a10189e6ac2a5f696b839f to your computer and use it in GitHub Desktop.
<?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