Skip to content

Commit

Permalink
👌 IMPROVE: Background CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
austinginder committed Nov 18, 2024
1 parent 2d5c6d2 commit 552e0c3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/ProviderAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public function run() {
}
}
\CaptainCore\ProcessLog::insert( "Created site", $site_id );
captaincore_run_background_command( "site sync $site_id --update-extras" );
\CaptainCore\Run::CLI("site sync $site_id --update-extras");
}
}

Expand Down
8 changes: 6 additions & 2 deletions app/Run.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Run {

protected $account_id = "";

public static function CLI( $command = "" ) {
public static function CLI( $command = "", $background = false ) {

if ( empty( $command ) ) {
return;
Expand All @@ -29,7 +29,11 @@ public static function CLI( $command = "" ) {
];

// Add command to dispatch server
$response = wp_remote_post( CAPTAINCORE_CLI_ADDRESS . "/run", $data );
$url = CAPTAINCORE_CLI_ADDRESS . "/run";
if ( $background ) {
$url = CAPTAINCORE_CLI_ADDRESS . "/run/background";
}
$response = wp_remote_post( $url, $data );
if ( is_wp_error( $response ) ) {
$error_message = $response->get_error_message();
return [];
Expand Down

0 comments on commit 552e0c3

Please sign in to comment.