You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue:
I ran a simple http server script using swoole 6 and SWOOLE_THREAD mode, the var_dump($server->setting) of onTask and onWorkerStart callback show NULL, but in SWOOLE_PROCESS mode they show an setting array. Is this an expected behaviour or not?
1. What did you do? If possible, provide a simple script for reproducing the error.
I ran this script with Swoole 6
<?phprequire_once__DIR__ . '/../vendor/autoload.php';
useSwoole\Constant;
useSwoole\Http\Request;
useSwoole\Http\Response;
useSwoole\Http\Server;
$server = newServer('0.0.0.0', 3001, SWOOLE_THREAD);
$server->set([
'hook_flags' => SWOOLE_HOOK_ALL,
'enable_coroutine' => true,
'task_enable_coroutine' => false,
'debug_mode' => true,
'display_errors' => true,
'enable_preemptive_scheduler' => true,
'worker_num' => 4,
'reactor_num' => 2,
'task_worker_num' => 2
]);
$server->on(Constant::EVENT_WORKER_START, function (Server$server) {
var_dump($server->setting);
$pid = getmypid();
printf("Worker start on $pid\n");
});
$server->on('Task', function (Server$server, $task) {
var_dump($server->setting);
});
$server->on('request', function (Request$request, Response$response) use ($server) {
$server->taskWaitMulti([
"AA"
]);
$response->end("OK");
});
$pid = getmypid();
printf("[thread] Server started at http://0.0.0.0:$server->port on process {$pid}\n");
$server->start();
2. What did you expect to see?
the var_dump($server->setting) of onTask and onWorkerStart callback show array of value.
3. What did you see instead?
the var_dump($server->setting) of onTask and onWorkerStart callback show NULL.
4. What version of Swoole are you using (show your php --ri swoole)?
swoole
Swoole => enabled
Author => Swoole Team <[email protected]>
Version => 6.0.0
Built => Dec 25 2024 10:41:50
coroutine => enabled with boost asm context
epoll => enabled
eventfd => enabled
thread => enabled
signalfd => enabled
cpu_affinity => enabled
spinlock => enabled
rwlock => enabled
openssl => OpenSSL 3.0.2 15 Mar 2022
dtls => enabled
http2 => enabled
json => enabled
pcre => enabled
zlib => 1.2.11
brotli => E16777225/D16777225
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
Directive => Local Value => Master Value
swoole.enable_library => On => On
swoole.enable_fiber_mock => Off => Off
swoole.enable_preemptive_scheduler => Off => Off
swoole.display_errors => On => On
swoole.use_shortname => On => On
swoole.unixsock_buffer_size => 8388608 => 8388608
5. What is your machine environment used (show your uname -a & php -v & gcc -v) ?
uname -a
Linux PF4GRXXV 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
php -v
PHP 8.4.2 (cli) (built: Dec 25 2024 09:55:31) (ZTS)
Copyright (c) The PHP Group
Zend Engine v4.4.2, Copyright (c) Zend Technologies
with Zend OPcache v8.4.2, Copyright (c), by Zend Technologies
The text was updated successfully, but these errors were encountered:
nguyenhothanhtam0709
changed the title
$server->setting is NULL in onWorkerStart callback
$server->setting is NULL in onWorkerStart and onTask callback
Jan 2, 2025
Issue:
I ran a simple http server script using swoole 6 and SWOOLE_THREAD mode, the var_dump($server->setting) of onTask and onWorkerStart callback show NULL, but in SWOOLE_PROCESS mode they show an setting array. Is this an expected behaviour or not?
1. What did you do? If possible, provide a simple script for reproducing the error.
I ran this script with Swoole 6
2. What did you expect to see?
the var_dump($server->setting) of onTask and onWorkerStart callback show array of value.
3. What did you see instead?
the var_dump($server->setting) of onTask and onWorkerStart callback show NULL.
4. What version of Swoole are you using (show your php --ri swoole)?
5. What is your machine environment used (show your
uname -a
&php -v
&gcc -v
) ?uname -a
Linux PF4GRXXV 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
php -v
gcc -v
The text was updated successfully, but these errors were encountered: