Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid server options #49

Open
ghnp5 opened this issue Jun 26, 2023 · 8 comments
Open

Invalid server options #49

ghnp5 opened this issue Jun 26, 2023 · 8 comments

Comments

@ghnp5
Copy link

ghnp5 commented Jun 26, 2023

I followed this example as a template for my server config:
https://openswoole.com/docs/modules/swoole-server/configuration

However, it appears that a number of settings are invalid:

OpenSwoole\Server\Port::set(): Invalid server option: request_slowlog_file
OpenSwoole\Server\Port::set(): Invalid server option: pipe_buffer_size
OpenSwoole\Server\Port::set(): Invalid server option: dns_cache_refresh_time
OpenSwoole\Server\Port::set(): Invalid server option: enable_preemptive_scheduler
OpenSwoole\Server\Port::set(): Invalid server option: open_fastcgi_protocol
OpenSwoole\Server\Port::set(): Invalid server option: enable_object

pecl list | grep swoole

openswoole 22.0.0 stable

@mertingen
Copy link

Hi @ghnp5

Can you show how you set those options as code? My guess is you try to fix the "PORT" configuration with server options. Thus, they're invalid. "PORT" cannot recognize server options.

OpenSwoole\Server\Port::set():

@ghnp5
Copy link
Author

ghnp5 commented Jul 2, 2023

Hi,

Thank you for your reply.

I have basically copy/pasted the server config code example in https://openswoole.com/docs/modules/swoole-server/configuration

Like this:

$cpus = \OpenSwoole\Util::getCPUNum();

$OPENSWOOLE_DEFAULTS = [
	// Process
	'daemonize' => 0,
	'user' => 'www-data',
	'group' => 'www-data',
	....
	....
	....
];

(...)

$server = new Server('*', 9000, \OpenSwoole\Server::POOL_MODE, \OpenSwoole\Constant::SOCK_TCP);
$server->set($OPENSWOOLE_DEFAULTS);

On the call to $server->set(...), I get the crashes above, until I remove the invalid server options from the $OPENSWOOLE_DEFAULTS array, which I copied from https://openswoole.com/docs/modules/swoole-server/configuration

Thank you very much.

@mertingen
Copy link

Hi @ghnp5 ,

What is the namespace of "Server" class? You can see it initial of that file with "use" keyword. It should be the following one;

$server = new OpenSwoole\HTTP\Server("127.0.0.1", 9501);

Maybe that "Server" class refers to "OpenSwoole\Server\Port" in your file.

@ghnp5
Copy link
Author

ghnp5 commented Jul 2, 2023

Thanks. What I have is this:

use OpenSwoole\Http\Request;
use OpenSwoole\Http\Response;
use OpenSwoole\Http\Server;

@mertingen
Copy link

mertingen commented Jul 2, 2023

I'm just a user of Swoole but the docs say the following one, can you try it again? If it doesn't work I'll try to reproduce it because I wondered the solution.

$server = new OpenSwoole\Server

https://openswoole.com/docs/modules/swoole-server/configuration

@ghnp5
Copy link
Author

ghnp5 commented Jul 3, 2023

Where in the docs does it say like that?

In the Get Started (and all other examples I've seen), it has the way I have it now.

https://openswoole.com/docs/get-started-swoole

<?php

use OpenSwoole\Http\Server;
use OpenSwoole\Http\Request;
use OpenSwoole\Http\Response;

$server = new OpenSwoole\HTTP\Server("127.0.0.1", 9501);

@mertingen
Copy link

For example, on this page

https://openswoole.com/docs/modules/swoole-server/configuration

It says; "OpenSwoole Server configurations can be set with $server->set once you have created your server with $server = new OpenSwoole\Server."

@borys-p
Copy link

borys-p commented Jul 18, 2023

I just ran into similar issue when trying to set request_slowlog_file in Laravel Octane running on top of OpenSwoole.

Here's how they configure it, using the Swoole namespace for compatibility (Octane supports both Swoole and OpenSwoole):

$server = new Swoole\Http\Server( /* ... */ );
$server->set(array_merge(
    $serverState['defaultServerOptions'],
    $config['swoole']['options'] ?? []
));

Any my options are pretty simple:

'swoole' => [
		'options' => [
			'request_slowlog_file' => storage_path('logs/swoole_slow.log'),
			'request_slowlog_timeout' => 2,
			'trace_event_worker' => true,
		],
	],

PHP 8.2.7, OpenSwoole 22.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants