Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions src/helper/class-ee-site.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,15 @@ abstract class EE_Site_Command {
public function __construct() {

$this->fs = new Filesystem();
pcntl_signal( SIGTERM, [ $this, 'rollback' ] );
pcntl_signal( SIGHUP, [ $this, 'rollback' ] );
pcntl_signal( SIGUSR1, [ $this, 'rollback' ] );
pcntl_signal( SIGINT, [ $this, 'rollback' ] );
// A PHP without pcntl, or with it in disable_functions (fatal on PHP 8), only loses the rollback on signals.
if ( function_exists( 'pcntl_signal' ) ) {
pcntl_signal( SIGTERM, [ $this, 'rollback' ] );
pcntl_signal( SIGHUP, [ $this, 'rollback' ] );
pcntl_signal( SIGUSR1, [ $this, 'rollback' ] );
pcntl_signal( SIGINT, [ $this, 'rollback' ] );
} else {
EE::debug( 'PHP function pcntl_signal() is unavailable, so site commands interrupted by a signal (e.g. Ctrl+C) are not rolled back.' );
Comment thread
mrrobot47 marked this conversation as resolved.
Resolved
}
$shutdown_handler = new Shutdown_Handler();
register_shutdown_function( [ $shutdown_handler, 'cleanup' ], [ &$this ] );
}
Expand Down Expand Up @@ -1768,7 +1773,9 @@ private function acquire_ssl_lock( $throw = false, $wait = self::SSL_LOCK_WAIT_S
}
sleep( 1 );
// This file has no declare(ticks), so run pending SIGINT/SIGTERM handlers here or Ctrl-C can't end the wait.
pcntl_signal_dispatch();
if ( function_exists( 'pcntl_signal_dispatch' ) ) {
pcntl_signal_dispatch();
}
}
}

Expand Down Expand Up @@ -2450,6 +2457,11 @@ public function share( $args, $assoc_args ) {
$this->fs = new Filesystem();
$ngrok = EE_SERVICE_DIR . '/ngrok/ngrok';

// Everything but a plain --disable starts ngrok with shell_exec().
if ( ( ! $disable || $refresh ) && ! function_exists( 'shell_exec' ) ) {
EE::error( 'Sharing a site needs the PHP function shell_exec(), which this PHP disables. Remove it from disable_functions for the PHP CLI.' );
}

if ( $disable || $refresh ) {
if ( $this->site_data->site_url === $active_publish ) {
$this->ngrok_curl( false, $refresh );
Expand Down
Loading