Php symfony2 gearman worker在清除缓存时停止
我在我的symfony2.4项目中实现了 我有一个网站,用户可以采取行动并触发工作 比如: 我有一个工人可以无限地运行并执行作业迭代:0 我在后台从命令行运行过一次:Php symfony2 gearman worker在清除缓存时停止,php,symfony,doctrine-orm,backgroundworker,gearman,Php,Symfony,Doctrine Orm,Backgroundworker,Gearman,我在我的symfony2.4项目中实现了 我有一个网站,用户可以采取行动并触发工作 比如: 我有一个工人可以无限地运行并执行作业迭代:0 我在后台从命令行运行过一次: nohup php /myproject/app/console gearman:worker:execute MYBundleServicesPublishWorker > /tmp/error_log.txt > /tmp/output_log.txt & 配置如下所示: gearman: # Bu
nohup php /myproject/app/console gearman:worker:execute MYBundleServicesPublishWorker > /tmp/error_log.txt > /tmp/output_log.txt &
配置如下所示:
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
我的问题是,当我运行应用程序/控制台缓存时:清除该作业,然后进入工作崩溃
其抛出错误:
PHP警告:
需要_once/myproject/app/cache/dev/jms_diextra/doctrine/EntityManager_53a06fb21b4.php:
无法打开流:中没有此类文件或目录
/第787行的myproject/app/cache/dev/appDevDebugProjectContainer.php
PHP致命错误:需要\u一次:需要打开失败
“/myproject/app/cache/dev/jms_diextra/doctrine/EntityManager_53a06fbf221b4.php”
将_path=':/usr/share/php:/usr/share/pear'包含在
/第787行的myproject/app/cache/dev/appDevDebugProjectContainer.php
如何修复它,我尝试更改doctrine bundle缓存类型:file\u system/array/apc
但这没有帮助
我怎样才能克服这个问题?
我做错了什么
提前感谢我发现了问题,我的员工在这一行:
$this->doctrine->resetEntityManager();
所以呢,
现在,我只是打开连接并关闭它,就像:
$em = $this->doctrine->getEntityManager();
$em->getConnection()->connect();
# run publish command
............
# close connection
$em->getConnection()->close();
$em = $this->doctrine->getEntityManager();
$em->getConnection()->connect();
# run publish command
............
# close connection
$em->getConnection()->close();