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

Restarting the php process via supervisorctl triggers a deprecation warning in symfony/console #718

Closed
borys-p opened this issue Jul 12, 2023 · 8 comments · Fixed by #722

Comments

@borys-p
Copy link

borys-p commented Jul 12, 2023

Octane Version

2.0.1

Laravel Version

10.14.1

PHP Version

8.2.7

What server type are you using?

Open Swoole

Server Version

22.0.0

Database Driver & Version

No response

Description

I set up supervisorctl in the local Docker environment to have an easy way to restart PHP after making some changes to the modules configuration. However, each attempt to restart php with:

supervisor> restart php
php: stopped
php: started
supervisor>

results in the following deprecation error being thrown in the console:

"Since symfony/console 6.3: Not returning an exit code from "Laravel\Octane\Commands\StartCommand::handleSignal()" is deprecated, return "false" to keep the command running or "0" to exit successfully."
array:32 [
  0 => array:5 [
    "file" => "/application/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php"
    "line" => 255
    "function" => "handleError"
    "class" => "Illuminate\Foundation\Bootstrap\HandleExceptions"
    "type" => "->"
  ]
  1 => array:3 [
    "function" => "Illuminate\Foundation\Bootstrap\{closure}"
    "class" => "Illuminate\Foundation\Bootstrap\HandleExceptions"
    "type" => "->"
  ]
  2 => array:3 [
    "file" => "/application/vendor/symfony/deprecation-contracts/function.php"
    "line" => 25
    "function" => "trigger_error"
  ]
  3 => array:3 [
    "file" => "/application/vendor/symfony/console/Application.php"
    "line" => 1031
    "function" => "trigger_deprecation"
  ]
  4 => array:5 [
    "file" => "/application/vendor/symfony/console/SignalRegistry/SignalRegistry.php"
    "line" => 54
    "function" => "Symfony\Component\Console\{closure}"
    "class" => "Symfony\Component\Console\Application"
    "type" => "->"
  ]
  5 => array:5 [
    "file" => "/application/vendor/laravel/octane/src/Commands/Concerns/InteractsWithServers.php"
    "line" => 31
    "function" => "handle"
    "class" => "Symfony\Component\Console\SignalRegistry\SignalRegistry"
    "type" => "->"
  ]
  6 => array:5 [
    "file" => "/application/vendor/laravel/octane/src/Commands/StartSwooleCommand.php"
    "line" => 88
    "function" => "runServer"
    "class" => "Laravel\Octane\Commands\StartSwooleCommand"
    "type" => "->"
  ]
  7 => array:5 [
    "file" => "/application/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php"
    "line" => 36
    "function" => "handle"
    "class" => "Laravel\Octane\Commands\StartSwooleCommand"
    "type" => "->"
  ]
  8 => array:5 [
    "file" => "/application/vendor/laravel/framework/src/Illuminate/Container/Util.php"
    "line" => 41
    "function" => "Illuminate\Container\{closure}"
    "class" => "Illuminate\Container\BoundMethod"
    "type" => "::"
  ]
  9 => array:5 [
    "file" => "/application/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php"
    "line" => 93
    "function" => "unwrapIfClosure"
    "class" => "Illuminate\Container\Util"
    "type" => "::"
  ]
  10 => array:5 [
    "file" => "/application/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php"
    "line" => 35
    "function" => "callBoundMethod"
    "class" => "Illuminate\Container\BoundMethod"
    "type" => "::"
  ]
  11 => array:5 [
    "file" => "/application/vendor/laravel/framework/src/Illuminate/Container/Container.php"
    "line" => 662
    "function" => "call"
    "class" => "Illuminate\Container\BoundMethod"
    "type" => "::"
  ]
  12 => array:5 [
    "file" => "/application/vendor/laravel/framework/src/Illuminate/Console/Command.php"
    "line" => 208
    "function" => "call"
    "class" => "Illuminate\Container\Container"
    "type" => "->"
  ]
  13 => array:5 [
    "file" => "/application/vendor/symfony/console/Command/Command.php"
    "line" => 326
    "function" => "execute"
    "class" => "Illuminate\Console\Command"
    "type" => "->"
  ]
  14 => array:5 [
    "file" => "/application/vendor/laravel/framework/src/Illuminate/Console/Command.php"
    "line" => 177
    "function" => "run"
    "class" => "Symfony\Component\Console\Command\Command"
    "type" => "->"
  ]
  15 => array:5 [
    "file" => "/application/vendor/laravel/framework/src/Illuminate/Console/Concerns/CallsCommands.php"
    "line" => 67
    "function" => "run"
    "class" => "Illuminate\Console\Command"
    "type" => "->"
  ]
  16 => array:5 [
    "file" => "/application/vendor/laravel/framework/src/Illuminate/Console/Concerns/CallsCommands.php"
    "line" => 28
    "function" => "runCommand"
    "class" => "Illuminate\Console\Command"
    "type" => "->"
  ]
  17 => array:5 [
    "file" => "/application/vendor/laravel/octane/src/Commands/StartCommand.php"
    "line" => 60
    "function" => "call"
    "class" => "Illuminate\Console\Command"
    "type" => "->"
  ]
  18 => array:5 [
    "file" => "/application/vendor/laravel/octane/src/Commands/StartCommand.php"
    "line" => 47
    "function" => "startSwooleServer"
    "class" => "Laravel\Octane\Commands\StartCommand"
    "type" => "->"
  ]
  19 => array:5 [
    "file" => "/application/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php"
    "line" => 36
    "function" => "handle"
    "class" => "Laravel\Octane\Commands\StartCommand"
    "type" => "->"
  ]
  20 => array:5 [
    "file" => "/application/vendor/laravel/framework/src/Illuminate/Container/Util.php"
    "line" => 41
    "function" => "Illuminate\Container\{closure}"
    "class" => "Illuminate\Container\BoundMethod"
    "type" => "::"
  ]
  21 => array:5 [
    "file" => "/application/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php"
    "line" => 93
    "function" => "unwrapIfClosure"
    "class" => "Illuminate\Container\Util"
    "type" => "::"
  ]
  22 => array:5 [
    "file" => "/application/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php"
    "line" => 35
    "function" => "callBoundMethod"
    "class" => "Illuminate\Container\BoundMethod"
    "type" => "::"
  ]
  23 => array:5 [
    "file" => "/application/vendor/laravel/framework/src/Illuminate/Container/Container.php"
    "line" => 662
    "function" => "call"
    "class" => "Illuminate\Container\BoundMethod"
    "type" => "::"
  ]
  24 => array:5 [
    "file" => "/application/vendor/laravel/framework/src/Illuminate/Console/Command.php"
    "line" => 208
    "function" => "call"
    "class" => "Illuminate\Container\Container"
    "type" => "->"
  ]
  25 => array:5 [
    "file" => "/application/vendor/symfony/console/Command/Command.php"
    "line" => 326
    "function" => "execute"
    "class" => "Illuminate\Console\Command"
    "type" => "->"
  ]
  26 => array:5 [
    "file" => "/application/vendor/laravel/framework/src/Illuminate/Console/Command.php"
    "line" => 177
    "function" => "run"
    "class" => "Symfony\Component\Console\Command\Command"
    "type" => "->"
  ]
  27 => array:5 [
    "file" => "/application/vendor/symfony/console/Application.php"
    "line" => 1081
    "function" => "run"
    "class" => "Illuminate\Console\Command"
    "type" => "->"
  ]
  28 => array:5 [
    "file" => "/application/vendor/symfony/console/Application.php"
    "line" => 320
    "function" => "doRunCommand"
    "class" => "Symfony\Component\Console\Application"
    "type" => "->"
  ]
  29 => array:5 [
    "file" => "/application/vendor/symfony/console/Application.php"
    "line" => 174
    "function" => "doRun"
    "class" => "Symfony\Component\Console\Application"
    "type" => "->"
  ]
  30 => array:5 [
    "file" => "/application/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php"
    "line" => 200
    "function" => "run"
    "class" => "Symfony\Component\Console\Application"
    "type" => "->"
  ]
  31 => array:5 [
    "file" => "/application/artisan"
    "line" => 35
    "function" => "handle"
    "class" => "Illuminate\Foundation\Console\Kernel"
    "type" => "->"
  ]
]

Steps To Reproduce

Use the following supervisord.conf file (some paths might need to be adjusted depending on the environment):

[unix_http_server]
file=/tmp/supervisor.sock

[supervisord]
nodaemon=true
user=root
logfile=/var/log/supervisord.log
pidfile=/var/run/supervisord.pid

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///tmp/supervisor.sock

[program:php]
command=/usr/local/bin/php -d variables_order=EGPCS /application/artisan octane:start --server=swoole --host=0.0.0.0 --port=80 --watch
user=www-data
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

Then run supervisorctl and execute restart php. Make sure you have deprecations logger set up. You should see an error in the console.

@driesvints
Copy link
Member

Does the process halt all together or is the deprecation just something annoying that's popping up?

@borys-p
Copy link
Author

borys-p commented Jul 13, 2023

It restarts correctly, so it's more of an annoyance until Symfony decides to enforce that return value.

@driesvints
Copy link
Member

Hi @borys-p. I'm sorry but afaik the StartCommand always returns an exit code so I cannot see how this error could occur... Right now we only have one report of this so I'm going to close this one as it's only a deprecation and not an error. If we get more reports we could dig deeper into it. Of course if you can pinpoint where things might go wrong that could help.

@borys-p
Copy link
Author

borys-p commented Jul 18, 2023

Hey @driesvints, according to the error message the issue is located in StartCommand::handleSignal() and that one is indeed not returning anything:

    /**
     * The method will be called when the application is signaled.
     */
    public function handleSignal(int $signal): void
    {
        $this->stopServer();
    }

Probably a simple return 0; will suffice.

@driesvints
Copy link
Member

There's no such method in that class: https://github.com/laravel/octane/blob/2.x/src/Commands/StartCommand.php

@saulens22
Copy link

@driesvints
Copy link
Member

@saulens22 thanks for pointing that out! Seems @sy-records already sent in a PR so that should be solved soon.

@silverm0on
Copy link

Put two new parameters into config belongs to your process with <your_process> name

#/etc/supervisorctl/conf.d/your_process.conf

[program:<your_process>]
...
stopasgroup=true
stopsignal=QUIT

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

Successfully merging a pull request may close this issue.

4 participants