Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using laravel queue fails to run on my shared hosting solution

Trying to get queue to work on my shared host,

  • I have set up a cron job to run 'php artisan queue:work' every minute.
  • I am using the database driver
  • The jobs get into the jobs table fine
  • If I am using sync driver, it works on my shared host On my developer machine, it works both with Sync and Database driver.
  • I dont fell Laravel Queue: How to use on shared hosting provides a sufficient answer since I have cron possibility and therefore I would like to get it working with the database driver
  • php is version 5.5 both from cli and web interface.

php artisan queue:work on my shared host (via cron) returns

[ErrorException] 
Invalid argument supplied for foreach()

in my log file the following is written.

[2015-04-12 18:59:01] production.ERROR: exception 'ErrorException' with message 'Invalid argument supplied for foreach()' in /home/a109/vendor/symfony/console/Symfony/Component/Console/Input/ArgvInput.php:287 Stack trace:
#0 /home/a109/vendor/symfony/console/Symfony/Component/Console/Input/ArgvInput.php(287): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'Invalid argumen...', '/home/a109/vend...', 287, Array)
#1 /home/a109/vendor/symfony/console/Symfony/Component/Console/Application.php(823): Symfony\Component\Console\Input\ArgvInput->hasParameterOption(Array)
#2 /home/a109/vendor/symfony/console/Symfony/Component/Console/Application.php(123): Symfony\Component\Console\Application->configureIO(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /home/a109/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(94): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 /home/a109/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 {main}

at line 287 in vendor/symfony/console/Symfony/Component/Console/Input/ArgvInput.php there is this function

  /**
 * Returns true if the raw parameters (not parsed) contain a value.
 *
 * This method is to be used to introspect the input parameters
 * before they have been validated. It must be used carefully.
 *
 * @param string|array $values The value(s) to look for in the raw parameters (can be an array)
 *
 * @return bool true if the value is contained in the raw parameters
 */
public function hasParameterOption($values)
{
    $values = (array) $values;

    foreach ($this->tokens as $token) {
        foreach ($values as $value) {
            if ($token === $value || 0 === strpos($token, $value.'=')) {
                return true;
            }
        }
    }

    return false;
}

That is the sucker that fails.

How can I get this to work?

like image 350
buildcomplete Avatar asked Apr 12 '15 20:04

buildcomplete


People also ask

How do I run a queue in shared hosting?

As you mentioned you are using shared hosting, You follow the below steps. Step 2 you need to setup a cron job with with the following command php /path/to/application/artisan queue:work --queue=high,default . You can give a try. I hope it will work.

How do I know if my Laravel queue is working?

Show activity on this post. This is lower level but in the same vein you could run a command such as ps -aux | grep queue to literally view the running queue processes on whatever server your application/queue workers are running on.


1 Answers

answered by Comyn in #laravel at freenode

I had to change the cron command to this:

php -d register_argc_argv=On artisan queue:work
like image 127
buildcomplete Avatar answered Oct 06 '22 10:10

buildcomplete