php artisan queue:work --help Usage: queue:work [options] [--] [<connection>] Arguments: connection 队列连接redis、database等 Options: --queue[=QUEUE] 队列任务 --daemon 后台执行 --delay[=DELAY] 任务执行失败之后延迟多久重试 --force Force the worker to run even in maintenance mode --memory[=MEMORY] The memory limit in megabytes [default: 128] --sleep[=SLEEP] 队列无可用任务休息时间间隔,默认3s --tries[=TRIES] 失败任务最多重试次数 [default: 0] -h, --help 输出帮助信息 -q, --quiet 不输出信息 -V, --version Display this application version --ansi Force ANSI output --no-ansi Disable ANSI output -n, --no-interaction Do not ask any interactive question --env[=ENV] The environment the command should run under. -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug 使用案例 php artisan queue:work redis --queue=recommend --daemon --tries=1 备注: queue:work 默认只执行一次队列请求, 当请求执行完成后就终止; queue:listen 监听队列请求, 只要运行着, 就能一直接受请求, 除非手动终止; queue:work --daemon 同 listen 一样, 只要运行着, 就能一直接受请求, 不一样的地方是在这个运行模式下, 当新的请求到来的时候, 不重新加载整个框架, 而是直接 fire 动作. 能看出来, queue:work --daemon 是最高级的, 一般推荐使用这个来处理队列监听. 注意: 使用 queue:work --daemon , 当更新代码的时候, 需要停止, 然后重新启动, 这样才能把修改的代码应用上. 因此开发环境建议用queue:listen php artisan queue:listen --help Usage: queue:listen [options] [--] [<connection>] Arguments: connection The name of connection Options: --queue[=QUEUE] The queue to listen on --delay[=DELAY] Amount of time to delay failed jobs [default: 0] --memory[=MEMORY] The memory limit in megabytes [default: 128] --timeout[=TIMEOUT] Seconds a job may run before timing out [default: 60] --sleep[=SLEEP] Seconds to wait before checking queue for jobs [default: 3] --tries[=TRIES] Number of times to attempt a job before logging it failed [default: 0] -h, --help Display this help message -q, --quiet Do not output any message -V, --version Display this application version --ansi Force ANSI output --no-ansi Disable ANSI output -n, --no-interaction Do not ask any interactive question --env[=ENV] The environment the command should run under. -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug