Skip to content

Commit

Permalink
Fix for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
walkor authored Feb 19, 2023
1 parent 525533c commit 0df2093
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions Worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Worker
*
* @var string
*/
const VERSION = '4.1.7';
const VERSION = '4.1.8';

/**
* Status starting.
Expand Down Expand Up @@ -1450,11 +1450,39 @@ protected static function forkWorkersForWindows()
/** @var Worker $worker */
$worker = current(static::$_workers);

\Workerman\Timer::delAll();

//Update process state.
static::$_status = static::STATUS_RUNNING;

// Register shutdown function for checking errors.
\register_shutdown_function([__CLASS__, 'checkErrors']);

// Create a global event loop.
if (!static::$globalEvent) {
$eventLoopClass = static::getEventLoopName();
static::$globalEvent = new $eventLoopClass;
}

// Reinstall signal.
static::reinstallSignal();

// Init Timer.
Timer::init(static::$globalEvent);

\restore_error_handler();

// Display UI.
static::safeEcho(\str_pad($worker->name, 30) . \str_pad($worker->getSocketName(), 36) . \str_pad($worker->count, 10) . "[ok]\n");
static::safeEcho(\str_pad($worker->name, 21) . \str_pad($worker->getSocketName(), 36) . \str_pad((string)$worker->count, 10) . "[ok]\n");
$worker->listen();
$worker->run();
exit("@@@child exit@@@\r\n");
static::$globalEvent->loop();
if (static::$_status !== self::STATUS_SHUTDOWN) {
$err = new Exception('event-loop exited');
static::log($err);
exit(250);
}
exit(0);
}
else
{
Expand Down

0 comments on commit 0df2093

Please sign in to comment.