0
votes

I implementing Mmoreram gearman bundle in my symfony(2.4) project.

I have website that users make action and triggers jobs.

like:

 # Get Gearman and tell it to run in the background a 'job'
        $id = $this->params['gearman']->doHighBackgroundJob('MYBundleServicesPublishWorker~publish',
            json_encode($parameters)
        );

And i have one worker that run infinitely and do the jobs (iterations: 0)

I run it from command line once in background:

nohup php /myproject/app/console gearman:worker:execute MYBundleServicesPublishWorker > /tmp/error_log.txt > /tmp/output_log.txt &

The config look like:

gearman:
   # Bundles will parsed searching workers
   bundles:
      # Name of bundle
      MyBundle:

         # Bundle name
         name: myBundle

         # Bundle search can be enabled or disabled
         active: true

         # If any include is defined, Only these namespaces will be parsed
         # Otherwise, full Bundle will be parsed
         include:
            - Services
            - EventListener

         # Namespaces this Bundle will ignore when parsing
         ignore:
            - DependencyInjection
            - Resources

   # default values
   # All these values will be used if are not overwritten in Workers or jobs
   defaults:

      # Default method related with all jobs
      # do // deprecated as of pecl/gearman 1.0.0. Use doNormal
      # doNormal
      # doBackground
      # doHigh
      # doHighBackground
      # doLow
      # doLowBackground
      method: doNormal

      # Default number of executions before job dies.
      # If annotations defined, will be overwritten
      # If empty, 0 is defined by default
      iterations: 0

      # execute callbacks after operations using Kernel events
      callbacks: true

      # Prefix in all jobs
      # If empty name will not be modified
      # Useful for rename jobs in different environments
      job_prefix: null

      # Autogenerate unique key in jobs/tasks if not set
      # This key is unique given a Job name and a payload serialized
      generate_unique_key: true

      # Prepend namespace when callableName is built
      # By default this variable is set as true
      workers_name_prepend_namespace: true

   # Server list where workers and clients will connect to
   # Each server must contain host and port
   # If annotations defined, will be full overwritten
   #
   # If servers empty, simple localhost server is defined by default
   # If port empty, 4730 is defined by efault
   servers:
      localhost:
         host: 127.0.0.1
         port: 4730

doctrine_cache:
    providers:
        gearman_cache:
            type: apc
            namespace: doctrine_cache.ns.gearman
 

my problem is when i run app/console cache:clear and after that job come in the worker crash

its throw error :

PHP Warning: require_once(/myproject/app/cache/dev/jms_diextra/doctrine/EntityManager_53a06fbf221b4.php): failed to open stream: No such file or directory in /myproject/app/cache/dev/appDevDebugProjectContainer.php on line 787

PHP Fatal error: require_once(): Failed opening required '/myproject/app/cache/dev/jms_diextra/doctrine/EntityManager_53a06fbf221b4.php' (include_path='.:/usr/share/php:/usr/share/pear') in /myproject/app/cache/dev/appDevDebugProjectContainer.php on line 787

How can i fix it, i try to change the doctrine bundle cache type: file_system/array/apc but it did not help

How can i overcome this? what i am doing wrong?

Thanks in advance

1

1 Answers

0
votes

i found the problem, i have in my worker this line :

$this->doctrine->resetEntityManager();

that cause this,

now i am only open connection and close it like:

$em = $this->doctrine->getEntityManager();
$em->getConnection()->connect();

# run publish command
............
# close connection
$em->getConnection()->close();