openswoole / ext-openswoole

Programmatic server for PHP with async IO, coroutines and fibers
https://openswoole.com
Apache License 2.0
808 stars 51 forks source link

Urgent: PHP Fatal error: Swoole\Server::start(): failed to start server. Error: Server::start_check(): onTask event callback must be set. #247

Closed fakharksa closed 2 years ago

fakharksa commented 2 years ago
  1. What did you do? If possible, provide a simple script for reproducing the error.

    
    In server configuration, when i use            
    ` 'task_worker_num' => 8,  `
    
    ... and then run server ...

The server fails to start and gives error as mentioned in my response to your question 3 below.

Here is the configuration:

         $this->httpService->set([
            'daemonize'             => 1,
            'dispatch_mode'         => 1,
            'max_request'           => 8000,
            'open_tcp_nodelay'      => true,
            'reload_async'          => true,
            'max_wait_time'         => 60,
            'enable_reuse_port'     => true,
            'enable_coroutine'      => true,
            'static_handler_locations' => ['/static', '/app/images', '/releases'],
            'http_compression'      => false,
            'enable_static_handler' => true,
            'buffer_output_size'    => 4 * 1024 * 1024,
            'worker_num'            => 4, // Each worker holds a connection pool
            'task_worker_num' => 8,  // The amount of task workers to start
//            'task_enable_coroutine' => true,
        ]);
Note: I have tested the configuratoin by commenting and uncommenting all options, so the issue comes only when i uncomment 'task_worker_num' configuration key.
  1. What did you expect to see?
    
    Swoole HTTP Server should have run without Fatal Errors, as in previous versions.
3. What did you see instead?

WARNING Server::start_check(): onTask event callback must be set PHP Fatal error: Swoole\Server::start(): failed to start server. Error: Server::start_check(): onTask event callback must be set in [my_php_file_name_with_line_number]

4. What version of OpenSwoole are you using (show your `php --ri openswoole`)?

Openswoole version 4.11.1

I installed it using source

5. What is your machine environment used (show your `uname -a` & `php -v` & `gcc -v`) ?

Output of uname -a (where fakhar is my name in my computer-name "fakhar-HP-laptop". Linux fakhar-HP-Laptop 5.17.5-76051705-generic #202204271406~1651504840~20.04~63e51bd-Ubuntu SMP PREEMPT Wed Ma x86_64 x86_64 x86_64 GNU/Linux

"Output of php -v" PHP 8.1.10 (cli) (built: Sep 18 2022 10:26:02) (NTS) Copyright (c) The PHP Group Zend Engine v4.1.10, Copyright (c) Zend Technologies with Zend OPcache v8.1.10, Copyright (c), by Zend Technologies

"Output of gcc -v"

Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/11/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 11.2.0-19ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-11 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-11-gBFGDP/gcc-11-11.2.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-11-gBFGDP/gcc-11-11.2.0/debian/tmp-gcn/usr --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=2 Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 11.2.0 (Ubuntu 11.2.0-19ubuntu1)



You can also try the following OpenSwoole support channels:

* [Documentation](https://openswoole.com/docs) - Documentation for Open Swoole
* [Slack](https://goo.gl/forms/wooTTDmhbu30x4qC3) - Slack channel of Open Swoole
* [Discord](https://discord.gg/5QC57RNPpw) - Discord server of Open Swoole
doubaokun commented 2 years ago

You must set onTask callback according to https://openswoole.com/docs/modules/swoole-server-on-task

fakharksa commented 2 years ago

@doubaokun Why should i create an $server->on("Task", callback()); until i am actually using it ?

By principle, the "Server Configuration" should only create a Pool of "TaskWorker Process" in memory instead of forcing developer to create (feed) a (dummy) task.

By principle, a "configuration" should behave like a "declaration / prototype ", and should never force to provide a "definition / implementation" along with it).

Philosophy: I want to declare "i will / may use Task Worker Processes" as an Application Architect, but i do not want the developer to start with providing a dummy on("task", callback());

Plus, this is not how it was in earlier versions. Therefore, i request you to please consider it as a genuine issue/ bug.

doubaokun commented 2 years ago

If you enable 'task_worker_num' => 8, you must setup ontask callback. You can remove 'task_worker_num' => 8 if task workers are not used.