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

Possible bug Artisan::queue() with queue:work "The option does not exist" #17487

Closed
poppabear8883 opened this issue Jan 22, 2017 · 4 comments
Closed

Comments

@poppabear8883
Copy link
Contributor

poppabear8883 commented Jan 22, 2017

  • Laravel Version:
    5.3.29
  • PHP Version:
    5.6.27
  • Database Driver & Version:
    mysql Ver 14.14 Distrib 5.7.16, for Linux (x86_64) using EditLine wrapper

Description:

The "--owner" option does not exist.' in /var/www/clients/client4/web9/web/vendor/symfony/console/Input/ArrayInput.php:172

Steps To Reproduce:

Note 1: the command works perfectly fine via terminal manually

# php artisan make:module test --owner=web9 --group=client4 --quick
     0/4 [>---------------------------]   0%
    Warning: Changing owner and group 'web9:client4' for directory /var/www/clients/client4/web9/web/app/Modules/Test
     4/4 [============================] 100%
    Module generated successfully.

Note 2: takeing out --owner and --group the command works:

Artisan::queue('make:module', [
        'slug' => strtolower($name),
        '--quick' => true
]);

Supervisor configuration
Note: The reason that the worker runs as root user is that my jobs/commands require certain tasks to be done as the root user. The nature of this project is a server management interface. Hopefully that sheds some light to the type of methods i am trying to apply.

[program:nxpanel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/nxpanel.app/web/artisan queue:work database --sleep=3 --tries=3
autostart=true
autorestart=true
user=root
numprocs=8
redirect_stderr=true
stdout_logfile=/var/www/nxpanel.app/web/worker.log
// Methods that puts the command in queue
/**
 * Creates a module
 *
 * @param array $params
 * @return response
 */
protected function create($params = [])
{
    $validator = $this->valid_for_create($params);
 
    if ($validator->fails())
        return response(['errors' => $validator->failed()], 400);
 
    $owner = trim(exec('whoami'));
    $g = explode(' ', exec('groups'));
    $group = trim($g[0]);
 
    $module = $this->module->create($params['name'], $owner, $group);
    return response($module, 200);
}
 
public function create($name, $owner=null, $group=null)
{
    Artisan::queue('make:module', [
        'slug' => strtolower($name),
        '--owner' => $owner,
        '--group' => $group,
        '--quick' => true
    ]);
 
    return Module::getProperties(strtolower($name));
}
 
// The command signiture
protected $signature = 'make:module
        {slug : The slug of the module}
        {--owner= : The user}
        {--group= : The group}
        {--quick : Skip the make:module wizard and use default values}';
 
// PAYLOAD
{"job":"Illuminate\\Foundation\\Console\\QueuedJob","data":["make:module",{"slug":"test","--owner":"web9","--group":"client4","--quick":true}]}
 
// STACK TRACE
exception 'Symfony\Component\Console\Exception\InvalidOptionException' with message 'The "--owner" option does not exist.' in /var/www/clients/client4/web9/web/vendor/symfony/console/Input/ArrayInput.php:172
Stack trace:
#0 /var/www/clients/client4/web9/web/vendor/symfony/console/Input/ArrayInput.php(134): Symfony\Component\Console\Input\ArrayInput->addLongOption('owner', 'web9')
#1 /var/www/clients/client4/web9/web/vendor/symfony/console/Input/Input.php(62): Symfony\Component\Console\Input\ArrayInput->parse()
#2 /var/www/clients/client4/web9/web/vendor/symfony/console/Command/Command.php(219): Symfony\Component\Console\Input\Input->bind(Object(Symfony\Component\Console\Input\InputDefinition))
#3 /var/www/clients/client4/web9/web/vendor/laravel/framework/src/Illuminate/Console/Command.php(155): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArrayInput), Object(Symfony\Component\Console\Output\BufferedOutput))
#4 /var/www/clients/client4/web9/web/vendor/symfony/console/Application.php(821): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArrayInput), Object(Symfony\Component\Console\Output\BufferedOutput))
#5 /var/www/clients/client4/web9/web/vendor/symfony/console/Application.php(187): Symfony\Component\Console\Application->doRunCommand(Object(App\Console\Modules\Generators\MakeModuleCommand), Object(Symfony\Component\Console\Input\ArrayInput), Object(Symfony\Component\Console\Output\BufferedOutput))
#6 /var/www/clients/client4/web9/web/vendor/symfony/console/Application.php(118): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArrayInput), Object(Symfony\Component\Console\Output\BufferedOutput))
#7 /var/www/clients/client4/web9/web/vendor/laravel/framework/src/Illuminate/Console/Application.php(107): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArrayInput), Object(Symfony\Component\Console\Output\BufferedOutput))
#8 /var/www/clients/client4/web9/web/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(218): Illuminate\Console\Application->call('make:module', Array)
#9 [internal function]: Illuminate\Foundation\Console\Kernel->call('make:module', Array)
#10 /var/www/clients/client4/web9/web/vendor/laravel/framework/src/Illuminate/Foundation/Console/QueuedJob.php(36): call_user_func_array(Array, Array)
#11 /var/www/clients/client4/web9/web/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(73): Illuminate\Foundation\Console\QueuedJob->fire(Object(Illuminate\Queue\Jobs\DatabaseJob), Array)
#12 /var/www/clients/client4/web9/web/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(203): Illuminate\Queue\Jobs\Job->fire()
#13 /var/www/clients/client4/web9/web/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(154): Illuminate\Queue\Worker->process('database', Object(Illuminate\Queue\Jobs\DatabaseJob), Object(Illuminate\Queue\WorkerOptions))
#14 /var/www/clients/client4/web9/web/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(75): Illuminate\Queue\Worker->runNextJob('database', 'default', Object(Illuminate\Queue\WorkerOptions))
#15 /var/www/clients/client4/web9/web/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(101): Illuminate\Queue\Worker->daemon('database', 'default', Object(Illuminate\Queue\WorkerOptions))
#16 /var/www/clients/client4/web9/web/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(85): Illuminate\Queue\Console\WorkCommand->runWorker('database', 'default')
#17 [internal function]: Illuminate\Queue\Console\WorkCommand->fire()
#18 /var/www/clients/client4/web9/web/vendor/laravel/framework/src/Illuminate/Container/Container.php(508): call_user_func_array(Array, Array)
#19 /var/www/clients/client4/web9/web/vendor/laravel/framework/src/Illuminate/Console/Command.php(169): Illuminate\Container\Container->call(Array)
#20 /var/www/clients/client4/web9/web/vendor/symfony/console/Command/Command.php(254): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#21 /var/www/clients/client4/web9/web/vendor/laravel/framework/src/Illuminate/Console/Command.php(155): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#22 /var/www/clients/client4/web9/web/vendor/symfony/console/Application.php(821): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#23 /var/www/clients/client4/web9/web/vendor/symfony/console/Application.php(187): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#24 /var/www/clients/client4/web9/web/vendor/symfony/console/Application.php(118): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#25 /var/www/clients/client4/web9/web/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(121): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#26 /var/www/clients/client4/web9/web/artisan(36): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#27 {main}
@poppabear8883
Copy link
Contributor Author

poppabear8883 commented Jan 23, 2017

UPDATE: changing to optional OR required arguments yields the same issue

protected $signature = 'make:module
        {slug : The slug of the module}
        {owner? : The owner}
        {group? : The group}
        {--quick : Skip the make:module wizard and use default values}';

protected $signature = 'make:module
        {slug : The slug of the module}
        {owner : The owner}
        {group : The group}
        {--quick : Skip the make:module wizard and use default values}';

Artisan::queue('make:module', [
            'slug' => strtolower($name),
            'owner' => $owner,
            'group' => $group,
            '--quick' => true
        ]);

REMINDER:

the command works perfectly fine via terminal manually and the below works fine:

Artisan::queue('make:module', [
            'slug' => strtolower($name),
            //'owner' => $owner,
            //'group' => $group,
            '--quick' => true
        ]);

@poppabear8883
Copy link
Contributor Author

poppabear8883 commented Jan 23, 2017

Parser Tests don't seem to cover this scenario

https://github.com/laravel/framework/blob/5.3/tests/Console/ConsoleParserTest.php

Running this test PASSES: (Which confuses me even more)

$ ./vendor/bin/phpunit
PHPUnit 5.7.5 by Sebastian Bergmann and contributors.

..                                                                  2 / 2 (100%)

Time: 162 ms, Memory: 13.50MB

OK (2 tests, 9 assertions)
public function testMakeModuleParsing()
    {
        $results = Parser::parse('make:module
        {slug : The slug of the module}
        {owner : The owner}
        {group : The group}
        {--quick : Skip the make:module wizard and use default values}');

        $this->assertEquals('make:module', $results[0]);
        $this->assertEquals('slug', $results[1][0]->getName());
        $this->assertEquals('owner', $results[1][1]->getName());
        $this->assertEquals('group', $results[1][2]->getName());
        $this->assertEquals('quick', $results[2][0]->getName());
        $this->assertFalse($results[2][0]->acceptValue());
    }

@poppabear8883
Copy link
Contributor Author

poppabear8883 commented Jan 23, 2017

I think i have figured this issue out:

Code changes are not registered to the queue worker do to the queue:work bootstraping the applications state. The documentation does state this.

Issuing this command after making the changes to code seems to have solved the issue.

php artisan queue:restart

@edsonrodsilva
Copy link

@poppabear8883 Very good!
My God, I spent all day dealing with this problem.
This command: php artisan queue: restart saved me.

Thanks for sharing.

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

2 participants