Skip to content

Commit

Permalink
Consolident function req. to just shell_exec
Browse files Browse the repository at this point in the history
  • Loading branch information
Steveorevo committed Oct 25, 2023
1 parent 8b95e13 commit 0e97365
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions vscode.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,21 +151,20 @@ public function start() {
// Stop all VSCode services.
public function stop() {

// Find all node vscode processes
$cmd = 'ps ax | grep "/opt/vscode/node /opt/vscode/out/server-main.js" | grep -v grep';
exec($cmd, $processes);
// Find all node vscode processes
$cmd = 'ps ax | grep "/opt/vscode/node /opt/vscode/out/server-main.js" | grep -v grep';
$processes = explode( PHP_EOL, shell_exec( $cmd ) );

// Loop through each process and extract the process ID (PID)
foreach ($processes as $process) {
$pid = preg_replace('/^\s*(\d+).*$/', '$1', $process);
// Loop through each process and extract the process ID (PID)
foreach ($processes as $process) {
$pid = preg_replace('/^\s*(\d+).*$/', '$1', $process);

// Kill the process
$kill = "kill $pid";
exec($kill, $output, $returnValue);
// Kill the process
shell_exec( "kill $pid" );

global $hcpp;
$hcpp->log( "Killed node vscode process $pid" );
}
global $hcpp;
$hcpp->log( "Killed node vscode process $pid" );
}

// Remove service link and reload nginx
global $hcpp;
Expand Down

0 comments on commit 0e97365

Please sign in to comment.