GithubHelp home page GithubHelp logo

resquebundle / resque Goto Github PK

View Code? Open in Web Editor NEW
50.0 5.0 29.0 488 KB

ResqueBundle for Symfony 4+

License: MIT License

PHP 80.61% Twig 19.39%
hacktoberfest hacktoberfest2020 hacktoberfest2021

resque's Introduction

Scrutinizer Code Quality

This project IS NO LONGER UNDER ANY development (last major update September 2021)

If you would like to take over maintenance of this project please contact [email protected] - I no longer use the code here in any live project as I moved to Symfony Messenger, with Redis. for my own queue needs.

If you are using PHP 8 plesae see the php8 branch for the latest stable release

ResqueBundle

Compatibiltiy

  • For Symfony 5+ please use ResqueBundle v4.0.0+
  • For Symfony 4+ please use major series ResqueBundle v3+ and work towards Symfony 5 migration ;-)
  • For Symfony 3+ please peg to exact release ResqueBundle v2.0.9+ and think about your decision to even use Symfony 3 ;-)

Note that we dont offer the same b/c promise as symfony itself, but try our hardest to make major versions for major symfony versions.

Update May 2020

  • Inject ParameterBagInterface instead of directly accessing container in commands and controller
  • User kernel.project_dir instead of kernel.root_dir (b/c break!, you need to update your config yml)
  • Update Routing controller to use long syntax
  • Use @Bundle syntax for loading twig templates
  • force a minimum of Symfony 4.1.2 for critical security
  • Use correct Process function for max compatibility
  • Drop Symfony 3.4 support totally, sorry.

Update November 2019

I have now worked on the master branch to implement compatibility with Symfony 4+, using Dependancy injection instead of ContainerAwareJob.

If you are still using Symfony 3 then you MUST peg your composer.json to release 2.0.9

The first version of this bundle that is highly compatible with, and activly maintained, is 3.0.0

If you have used this before, and want to get up to date, then you need to

  • upgrade to 3.0.0+ version of this bundle
  • use Symfony 4 (im using 4.4.0RC1 at the moment)
  • change your Jobs to extend ResqueBundle\Resque\Job and not ContainerAwareJob
  • add __construct methods to inject your depenancies
  • remove ALL REFERENCES to the container or getContainer from your jobs
  • Enjoy!

ResqueBundle History

This is a fork of the BCCResqueBundle as *that bundle is no longer being actively maintained. There are a lot of outstanding issues, pull requests and bugs that need to be fixed in that project, with no activity, so we forked it, and will activly support and develop the code further in this repo.

This is also a rebrand of Mpclarkson\ResqueBundle to place the code under a GitHub Organisation for future proof distributed development

Contributions are welcome

The resque bundle provides integration of php-resque to Symfony4. It is inspired from resque, a Redis-backed Ruby library for creating background jobs, placing them on multiple queues, and processing them later.

Features:

  • Creating a Job, with container access in order to leverage your Symfony services
  • Enqueue a Job with parameters on a given queue
  • Creating background worker on a given queue
  • An interface to monitor your queues, workers and job statuses
  • Schedule jobs to run at a specific time or after a number of seconds delay
  • Auto re-queue failed jobs, with back-off strategies
  • Dependency Injection to Jobs

Installation and configuration:

Requirements

Symfony 4+

Get the bundle

To install, run composer req resquebundle/resque

Import the routing configuration

Add to the following to routing.yml:

# app/config/routing.yml
ResqueBundle:
    resource: "@ResqueBundle/Resources/config/routing.xml"
    prefix:   /resque

You can customize the prefix as you wish.

You can now access the dashboard at this url: /resque

To secure the dashboard, you can add the following to your security.yml, assuming your administrator role is ROLE_ADMIN

access_control:
  - { path: ^/resque, roles: ROLE_ADMIN }

Now only users with the role ROLE_ADMIN will be able to access the dashboard at this url: /resque

Optional, set configuration

You may want to add some configuration to your config.yml

# app/config/config.yml
resque:
    app_include: /pathto/bootstrap.php.cache # app include file if different from default (i.e. /var/bootstrap.php.cache)
    prefix: my-resque-prefix                 # optional prefix to separate Resque data per site/app
    redis:
        host: localhost                      # the redis host
        port: 6379                           # the redis port
        database: 1                          # the redis database
        password: ~                          # the redis password, defaults to null
    auto_retry: [0, 10, 60]                  # auto retry failed jobs
    worker:
        project_dir: path/to/worker/project_dir        # the project_dir of app that run workers (optional)

See the Auto retry section for more on how to use auto_retry.

Set worker: project_dir: in case job fails to run when worker systems are hosted on separate server/dir from the system creating the queue. When running multiple configured apps for multiple workers, all apps must be able to access by the same root_dir defined in worker: root_dir.

Creating a Job

A job is a subclass of the ResqueBundle\Resque\Job class.

You will be forced to implement the run method that will contain your job logic:

<?php

namespace My;

use ResqueBundle\Resque\Job;
use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\Common\Persistence\ObjectManager;

class MyJob extends Job
{
    /**
     * @var string The queue name
     */
    public $queue = 'myqueue';

    /**
     * @var ManagerRegistry
     */
    private $registry;
    
    /**
     * @var ObjectManager
     */
    private $em;

    /**
     * Use the __construct to inject your dependencies
     *
     * @param array           $args
     * @param ManagerRegistry $registry
     */
    public function __construct(
        $args = [],
        ManagerRegistry $registry
    ) {
        $this->registry      = $registry;
        $this->em            = $registry->getManager();
        parent::__construct($args);
    }

    public function run($args)
    {
        file_put_contents($args['file'], $args['content']);
    }
}

As you can see you get an $args parameter that is the array of arguments of your Job.

Adding a job to a queue

You can get the resque service simply by using the container. From your controller you can do:

<?php

// get resque (only if service has been made public - else USE DI LIKE YOU SHOULD)
// $resque = $this->get('ResqueBundle\Resque\Resque');

// create your job
$job = new MyJob();
$job->args = array(
    'file'    => '/tmp/file',
    'content' => 'hello',
);

// enqueue your job
$resque->enqueue($job);

Running a worker on a queue

Executing the following commands will create a work on :

  • the default queue : app/console resque:worker-start default
  • the q1 and q2 queue : app/console resque:worker-start q1,q2 (separate name with ,)
  • all existing queues : app/console resque:worker-start "*"

You can also run a worker foreground by adding the --foreground option;

By default VERBOSE environment variable is set when calling php-resque

  • --verbose option sets VVERBOSE
  • --quiet disables both so no debug output is thrown

See php-resque logging option : https://github.com/chrisboulton/php-resque#logging

Adding a delayed job to a queue

You can specify that a job is run at a specific time or after a specific delay (in seconds).

From your controller you can do:

<?php

// get resque (only if service has been made public - else use DI LIKE YOU SHOULD)
//$resque = $this->get('ResqueBundle\Resque\Resque');

// create your job
$job = new MyJob();
$job->args = array(
    'file'    => '/tmp/file',
    'content' => 'hello',
);

// enqueue your job to run at a specific \DateTime or int unix timestamp
$resque->enqueueAt(\DateTime|int $at, $job);

// or

// enqueue your job to run after a number of seconds
$resque->enqueueIn($seconds, $job);

You must also run a scheduledworker, which is responsible for taking items out of the special delayed queue and putting them into the originally specified queue.

app/console resque:scheduledworker-start

Stop it later with app/console resque:scheduledworker-stop.

Note that when run in background mode it creates a PID file in 'cache//resque_scheduledworker.pid'. If you clear your cache while the scheduledworker is running you won't be able to stop it with the scheduledworker-stop command.

Alternatively, you can run the scheduledworker in the foreground with the --foreground option.

Note also you should only ever have one scheduledworker running, and if the PID file already exists you will have to use the --force option to start a scheduledworker.

Manage production workers with supervisord

It's probably best to use supervisord (http://supervisord.org) to run the workers in production, rather than re-invent job spawning, monitoring, stopping and restarting.

Here's a sample conf file

[program:myapp_phpresque_default]
command = /usr/bin/php /home/sites/myapp/bin/console resque:worker-start high --env=prod --foreground --verbose
user = myusername
stopsignal=QUIT

[program:myapp_phpresque_scheduledworker]
command = /usr/bin/php /home/sites/myapp/prod/bin/console resque:scheduledworker-start --env=prod --foreground --verbose
user = myusername
stopsignal=QUIT

[group:myapp]
programs=myapp_phpresque_default,myapp_phpresque_scheduledworker

(If you use a custom Resque prefix, add an extra environment variable: PREFIX='my-resque-prefix')

Then in Capifony you can do

sudo supervisorctl stop myapp:* before deploying your app and sudo supervisorctl start myapp:* afterwards.

More features

Changing the queue

You can change a job queue just by setting the queue field of the job:

From within the job:

<?php

namespace My;

use ResqueBundle\Resque\Job;

class MyJob extends Job
{
    public function __construct()
    {
        $this->queue = 'my_queue';
    }

    public function run($args)
    {
        ...
    }
}

Or from outside the job:

<?php

// create your job
$job = new MyJob();
$job->queue = 'my_queue';

Stop a worker

Use the app/console resque:worker-stop command.

  • No argument will display running workers that you can stop.
  • Add a worker id to stop it: app/console resque:worker-stop ubuntu:3949:default
  • Add the --all option to stop all the workers.

Auto retry

You can have the bundle auto retry failed jobs by adding retry strategy for either a specific job, or for all jobs in general:

The following will allow Some\Job to retry 3 times.

  • right away
  • after a 10 second delay
  • after a 60 second delay
resque:
    redis:
        ....
    auto_retry:
        Some\Job: [0, 10, 60]

Setting strategy for all jobs:

resque:
    auto_retry: [0, 10, 60]

With default strategy for all but specific jobs:

resque:
    auto_retry:
    	default:        [0, 10, 60]
        Some\Job:       [0, 10, 120, 240]
        Some\Other\Job: [10, 30, 120, 600]

The default strategy (if provided) will be applied to all jobs that does not have a specific strategy attached. If not provided these jobs will not have auto retry.

You can disable auto_retry for selected jobs by using an empty array:

resque:
    auto_retry:
    	default:        [0, 10, 60]
        Some\Job:       []
        Some\Other\Job: [10, 30, 120, 600]

Here Some\Job will not have any auto_retry attached.

Please note

To use the auto_retry feature, you must also run the scheduler job:

app/console resque:scheduledworker-start

resque's People

Contributors

brianv avatar cocomode18 avatar danabrey avatar dirkaholic avatar elazer avatar eymengunay avatar kbsali avatar kgust avatar lenar avatar liav89 avatar lightglitch avatar lsv avatar mbourqui avatar mhor avatar monofone avatar mpclarkson avatar nicolasbadey avatar patromo avatar philetaylor avatar ruudk avatar scrutinizer-auto-fixer avatar t3chn0r avatar tobiaskluge avatar tonypiper avatar wasigh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

resque's Issues

Q: Clear all scheduled jobs?

Is there a way to clear all scheduled jobs similar to clearing a queue? I have tried both commands:

bin/console resque:clear-queue queue=scheduled
bin/console resque:clear-queue queue=delayed

and code (fails because $job is an array):

    $resque = $this->getContainer()->get('resque');
    $timestamps = $resque->getDelayedJobTimestamps();

    foreach ($timestamps as $timestamp) {
      $delayed = $resque->getJobsForTimestamp($timestamp[0]);
      foreach ($delayed as $job) {
        $resque->removedDelayed($job);
      }
    }

Or (have no effect):

    $resque = $this->getContainer()->get('resque');
    $resque->clearQueue('scheduled');
    $resque->clearQueue('delayed');

Any pointers to a solution?

does not comply with psr-4 autoloading standard

Deprecation Notice: Class ResqueBundle\Resque\JobTest located in ./vendor/resquebundle/resque/Tests/JobTest.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:185

Deprecation Notice: Class ResqueBundle\Resque\ResqueBundleTest located in ./vendor/resquebundle/resque/Tests/ResqueBundleTest.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:185

Question about documentation

Hi,

The docs state that:

"When running multiple configured apps for multiple workers, all apps must be able to access by the same root_dir defined in worker: root_dir."

(at the bottom of Optional, set configuration)

In other words, two different installations of a project with workers must live in the same server? Can't I have then workers wrapped into Docker containers to process jobs?

Maybe what this means is that if I have two different apps, then to process jobs from these two apps I need workers that share the root_dir? I just can't figure this out.

Thanks a lot!

PHP Notice on enqueueOnce

Hi,

I am using the enqueueOnce method, but I get those PHP Notices for this line:

PHP Notice:  Array to string conversion in [...]/vendor/resquebundle/resque/Resque.php on line 103

But my args are a simple array with strings as keys and values.

What should be done to prevent those notices?

Using:

  • PHP 7.2
  • Symfony 2.8.49
  • resquebundle/resque 2.0.6

Share symfony Kernel

Do you think is possible to share Symfony kernel booted instead of booting every time a job is processed?

Incompatible with Symfony 4

There are a few places that are not compatible with Symfony version 4.x.

  1. bootstrap.php.cache is not available in Symfony4. Therefore app_include is not valid any more, which affects logic in Configuration.php, ResqueExtension.php, StartWorkerCommand.php, StartScheduledWorkerCommand.php, resque-scheduler and resque.
  2. ContainerAwareJob::createKernel throw an error when instantiating Kernel class due to missing a namespace.
  3. Autowiring does not appear to work in a job class. Unable to use container->get('aService') even when the service is set to public.

Release of PHP8 branch?

Hi,

Since PHP 8.1 the way this bundle constructs commands is broken. I saw a fix commited to the PHP8 branch but this branch does not have a offical release/tag yet.

When will this branch be released?

Thanks!

Delayed jobs are not executed

Version: 4.1.2
Symfony: 4.4.18
PHP: 7.4.3

I followed the documentation to schedule delayed jobs, thus via:
$resque->enqueueIn($seconds, $job); in PHP after starting the scheduled worker app/console resque:scheduledworker-start

I can see on the resque homepage that the job is added to the scheduled queue. But the job is not transferred to the default queue at the expected timestamp, and is thus never executed.

Other jobs are normally executed via the standard workers.
Can you reproduce/acknowledge this issue? Or might it be related to the dependent library resque/php-resque?

On Symfony 5 - wrong return value for StartWorkerCommand::execute()

When running : php bin/console resque:worker-start "*" --verbose

I get the following :

Starting worker nohup /usr/bin/php7.4  /var/www/symfony/vendor/resquebundle/resque/Command/../bin/resque > /var/www/symfony/var/log/resque.log 2>&1 & echo $!
Worker started 8315b23b7b85:217:*

In Command.php line 261:
                                                                                                                         
  [TypeError]                                                                                                            
  Return value of "ResqueBundle\Resque\Command\StartWorkerCommand::execute()" must be of the type int, "null" returned.  
                                                                                                                         

Exception trace:
  at /var/www/symfony/vendor/symfony/console/Command/Command.php:261
 Symfony\Component\Console\Command\Command->run() at /var/www/symfony/vendor/symfony/console/Application.php:938
 Symfony\Component\Console\Application->doRunCommand() at /var/www/symfony/vendor/symfony/framework-bundle/Console/Application.php:96
 Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /var/www/symfony/vendor/symfony/console/Application.php:266
 Symfony\Component\Console\Application->doRun() at /var/www/symfony/vendor/symfony/framework-bundle/Console/Application.php:82
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /var/www/symfony/vendor/symfony/console/Application.php:142
 Symfony\Component\Console\Application->run() at /var/www/symfony/bin/console:43

resque:worker-start [-c|--count COUNT] [-i|--interval INTERVAL] [-f|--foreground] [-m|--memory-limit MEMORY-LIMIT] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command> <queues>

ContainerAwareJob getContainer() Broken

I updated composer for a symfony project and one of the

containerAwareJobs is now throwing a
Resque_Job_DirtyExitException
Job exited with exit code 255

I can boil it down to this line:

$this->getContainer()->get('doctrine')->getManager

I did a little digging and it looks like the

$this->kernel->boot(); in the abstract class "ContainerAwareJob" is giving the job problems. This is a resqueBundle problem - container works fine outside of the job. Is there something I could be missing? Any ideas? I know I could roll back composer, but I would rather a longer term solution be implemented.

Thanks,
Andrew

Deprecations Symfony 4.4

Hi there,

First of all, thanks for sharing this nice bundle! I am using this bundle in Symfony 4.4, but I encounter some deprecations:

Template reference "ResqueBundle::layout.html.twig" not found, did you mean "@Resque/layout.html.twig" in @Resque/Default/index.html.twig at line 1?

When loading the resque homepage. I can fix this by installing the templating package, but this is deprecated in Symfony 4.4

Resque commands are extending the ContainerAwareCommand class, instead of the Symfony Command class and using dependency injection.

I also see some other deprecation messages, but they are related to external packages.

Use callback for redis backend.

chrisboulton/php-resque is able to set redis server with a callback. This will allow us to use Predis instead of Credis (see chrisboulton/php-resque#248) as redis client. Predis supports multiple redis sentinels whilst Credis doesn't.

I have made some effort to use callback in this resquebundle without luck. Can someone point me to the right direction please? Thanks.

Symfony 4

Is it actually been tested in a symfony 4 app?

These are the problems I have

  • Commands not registered
  • $this->get('resque') is not public, so can not be used in the controller or in commands, when I change it to dependency injection, templates can not be found.

Using dev-master branch

Symfony 4 + Private services by default

I heard there are plans to make this library compatible with Symfony 4. One big issue is that services become private by default. That means that you cannot query them from the Container anymore.

Instead of telling users to make the services public, I think it would be good to find a solution within this bundle.

Currently, the Job is responsible for creating itself, the arguments, and the execution. In a very nasty way ($job->args) etc. What if we split this up in a Job and a JobHandler? That way, a JobHandler can be a Symfony service that is responsible for executing a given Job. The Job only contains the payload.

This would be a BC break of course.

WDYT?

Add option for blocking mode in console command

bin/resque checks for an environment variable BLOCKING to set working mode to blocking. But, different from other options (e.g. COUNT, INTERVAL), this one cannot be set with a command line argument when running bin/console resque:worker-start.

What do you think about adding this option to the command, something like --blocking or -b?

How can I set a Job priority

Imagine I have a process that queues some email alerts. Then, after these alerts have been queued, I get a new request and I need to queue a high priority task. By default, all Jobs are queued and processed as FIFO.

Is there a way to set-up priorities depending on the queued job, so we can specify what job needs to be processed first?

Thanks,

How to create jobs when it needs dependencies?

I try to upgrade from a very old version of ResqueBundle to the latest version but I cannot wrap my head around how I should replace ContainerAwareJob.

The readme gives this example job:

<?php

namespace My;

use ResqueBundle\Resque\Job;
use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\Common\Persistence\ObjectManager;

class MyJob extends Job
{
    /**
     * @var string The queue name
     */
    public $queue = 'myqueue';

    /**
     * @var ManagerRegistry
     */
    private $registry;
    
    /**
     * @var ObjectManager
     */
    private $em;

    /**
     * Use the __construct to inject your dependencies
     *
     * @param array           $args
     * @param ManagerRegistry $registry
     */
    public function __construct(
        $args = [],
        ManagerRegistry $registry
    ) {
        $this->registry      = $registry;
        $this->em            = $registry->getManager();
        parent::__construct($args);
    }

    public function run($args)
    {
        file_put_contents($args['file'], $args['content']);
    }
}

Then later explains how to enqueue the job:

// create your job
$job = new MyJob();
$job->args = array(
    'file'    => '/tmp/file',
    'content' => 'hello',
);

// enqueue your job
$resque->enqueue($job);

But how can this work? To create a MyJob instance I need to pass $args = [], ManagerRegistry $registry to the constructor.

Does that mean that the example should be like this?

// create your job
$job = new MyJob(
  array(
    'file'    => '/tmp/file',
    'content' => 'hello',
  ),
  $entityManager
);


// enqueue your job
$resque->enqueue($job);

Symfony 4 + Flex kernel creation compatibility

Overview
Symfony flex introduces the following changes that impact the ability for ContainerAwareJob::createKernel() from being able to work:

  • the kernel is namespaced
  • environment variables are used to provide application parameters

Problem 1: kernel namespacing
ContainerAwareJob::createKernel() attempts to find the correct kernel class, includes what is found with a require_once and assumes that the kernel's fully-qualified class name (FQCN) matches the kernel file name.

This latter assumption is false under Flex due to the kernel being namespaced.

A overly-complex set of kernel-guessing and error-catching blocks could possibly find the kernel and apply the correct namespace when instantiating. Such a solution is asking for trouble and will eventually fail.

Problem 2: Environment variables
Application parameters are provided via environment variables. In production, these are recommended to be defined in the web server config and in development these are recommended to come from a .env file. The latter (the .env file) is recommended for CLI usage.

Environment variables can be passed to bin/resque and this does work, however in production this may well mean needing to define sensitive environment variables within supervisor configuration in addition to however this may already be handled. This again is asking for trouble.

With no environment variables defined and with services dependent on environment variables, ContainerAwareJob::createKernel() will fail hard.

Proposed solution for kernel creation
Pass a KERNEL_CLASS environment variable to bin/resque such that ContainerAwareJob::createKernel() does not need to guess the kernel class name and won't need to care about what namespace the kernel may or may not live in.

This can be referenced in ContainerAwareJob::createKernel() via $_SERVER['KERNEL_CLASS'] and works just fine.

If KERNEL_CLASS is not defined, the current kernel-guessing behaviour can be used.

Proposed solution for environment variables
Pass a USE_DOT_ENV environment variable to bin/resque. If present in ContainerAwareJob::createKernel(), a call will be made to (new Dotenv())->load(__DIR__.'/../../../.env'); to load environment variables from a local .env file. This is how bin/console works and this seems a good practice to follow.

Upcoming PRs
@PhilETaylor I'll create a PR to handle both of the above.

worker getting stalled after running one task

Hi .
I am having this issue where the background worker is getting stalled after competing the first job in a Queue.

Example:

...................................................................................
...................................................................................
...................................................................................
[info] [19:56:48 2017-07-24] Checking default for jobs
[info] [19:56:48 2017-07-24] Sleeping for 5
[info] [19:56:53 2017-07-24] Checking default for jobs
[info] [19:56:53 2017-07-24] Sleeping for 5
[info] [19:56:58 2017-07-24] Checking default for jobs
[info] [19:56:58 2017-07-24] Sleeping for 5
[info] [19:57:03 2017-07-24] Checking default for jobs
[info] [19:57:03 2017-07-24] Found job on default

[notice] [19:57:03 2017-07-24] Starting work on (Job{default} | ID: 97ab28042n9ad4d900c459421eb06b
...
[info] [19:57:03 2017-07-24] Forked 25216 at 2017-07-24 19:57:03
.............
[info] [19:57:03 2017-07-24] Processing default since 2017-07-24 19:57:03
[notice] [19:57:07 2017-07-24] (Job{default} | ID: 97ab28042a369ad4d900c459421eb06b 
..... has finished

And after the first Job is finished, the worker is not showing the Polling message ( ie, checking default for jobs and sleeping for 5 ), and no messages are logged on the screen.

ENV

PHP 7.1.7-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Jul 7 2017 09:41:45) ( NTS )
Symfony version : v2.8.17
Redis server v=3.2.9

How to figure out why are the workers getting stalled ?

Thanks !

Dashboard no longer works!

Hi Phil!

In the docs you say

add __construct methods to inject your dependencies

But that breaks how php-resque instantiates jobs, and the dashboard no longer works.

Too few arguments to function App\MainBundle\Jobs\TrackerJob::__construct(), 0 passed in vendor/chrisboulton/php-resque/lib/Resque/Job/Factory.php on line 27 and exactly 2 expected
at src/MainBundle/Jobs/TrackerJob.php:38
  at App\MainBundle\Jobs\TrackerJob->__construct()
     (vendor/chrisboulton/php-resque/lib/Resque/Job/Factory.php:27)

Also do you have an example of a Job which is working for you in symfony 4, along with how you queue it?

Unable to find autoload.php, bootstrap.php.cache and Kernel.php

It seems that the autoload.php is not longer existing in the app directory in Symfony 3, which is required in bin/resque.

Because of that the worker fails with the following exception:

PHP Warning:  require(/code/vendor/resquebundle/resque/bin/../../../../app/autoload.php): failed to open stream: No such file or directory in /code/vendor/resquebundle/resque/bin/resque on line 9
PHP Stack trace:
PHP   1. {main}() /code/vendor/resquebundle/resque/bin/resque:0
PHP Fatal error:  require(): Failed opening required '/code/vendor/resquebundle/resque/bin/../../../../app/autoload.php' (include_path='.:/usr/share/php') in /code/vendor/resquebundle/resque/bin/resque on line 9
PHP Stack trace:
PHP   1. {main}() /code/vendor/resquebundle/resque/bin/resque:0

Maybe you should use the autoload.php in the vendor directory.

[EDIT]
Also the bootstrap.php.cache is not longer existing if you use Symfony Flex.
Additionally the worker is unable to load the Kernel of Symfony because the kernel is now located under the namespace App/Kernel.
Stacktrace of the Kernel issue:

PHP Fatal error:  Uncaught Error: Class 'Kernel' not found in /var/www/app/releases/20180225121150/vendor/resquebundle/resque/ContainerAwareJob.php:64
Stack trace:
#0 /var/www/app/releases/20180225121150/vendor/resquebundle/resque/ContainerAwareJob.php(44): ResqueBundle\Resque\ContainerAwareJob->createKernel()
#1 /var/www/app/releases/20180225121150/src/Job/AbstractJob.php(59): ResqueBundle\Resque\ContainerAwareJob->getContainer()
#2 /var/www/app/releases/20180225121150/src/Job/InstanceCreateJob.php(44): App\Job\AbstractJob->run(Array, true)
#3 /var/www/app/releases/20180225121150/vendor/resquebundle/resque/Job.php(57): App\Job\InstanceCreateJob->run(Array)
#4 /var/www/app/releases/20180225121150/vendor/chrisboulton/php-resque/lib/Resque/Job.php(194): ResqueBundle\Resque\Job->perform()
#5 /var/www/app/releases/20180225121150/vendor/chrisboulton/php-resque/lib/Resque/Worker.php(240): Resque_Job->perform()
#6 /var/www/app/releases/201 in /var/www/app/releases/20180225121150/vendor/resquebundle/resque/ContainerAwareJob.php on line 64

Throttling amount of child workers opened?

Hello,
first of all - thank you very much for making the bundle / expanding existing bundles..

I have the following:
a command which runs an Inventory Sync Worker - which in turn runs multiple Product Sync Workers.
Is there any easy way to throttle the amount of opened child workers (Product Sync Workers) within the Inventory Sync Worker until lets say as example 2 (of XX) have finished meaning as long as 2 are still running don't run another one?

Thanks in advance,
Din.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.