I am sending push notifications from my server and want it to simply be executed in a background process. I've read the Laravel docs and I know about database driver and some other options as well. I've got it working with database driver on my local machine but one thing is bugging me that I've to start a background thread to listen for jobs which gets added to the queue using php artisan queue:listen --deamon.

关键是,它总是像"老太婆"一样运行,消耗我的一些资源和内存.我只想在触发推送通知时创建一个新流程,它应该在添加后立即开始执行,之后该流程应该关闭.另一方面,对于laravel作业(job),我总是需要运行一个我想要避免的后台进程,而且我使用的是一个共享主机,它不允许我在服务器上安装"supervisor"来监控作业(job)的执行.

Can anyone clear this ambiguity?? What will be the better way to handle this scenario?

推荐答案

After some research, I've decided to go with database driver. There are some other great options as well, but the choice will depend on your system workload.

The point is, sync driver uses the main thread for execution of tasks which is useful for only when you are in development. If you have a production system then you might need to consider some other option to run your queue. The main idea of queuing long-running tasks is to be able to execute them in some background process so your main application thread won't block and you can serve your client requests more quickly.

For further information on different drivers and help please visit Laravel docs

Laravel相关问答推荐

Vue 组件中的图像不适用于 Vite + Laravel

Laravel 数据未传递到下拉框

如何返回Blade Laravel 中的按钮?

在 blade laravel 中以格式编号显示长数字

调用字符串上的成员函数

如何在 Laravel 的外部 js 文件中包含 csrf_token()?

Laravel 价格验证只接受正数而不是 0

具有实时和 WebSockets 的 Angular2 + Laravel

条带 api 判断现有卡

Homebrew PHP 似乎没有链接

干预图像:直接从带有原始文件名和分机的网址保存图像?

Laravel 5 - 为包创建 Artisan 命令

Laravel 4 上传图片表单

Laravel 5.3 通知 - 仅使用Electron邮件地址通知

如何在 Laravel 测试中禁用选定的中间件

如何使用队列设置高、低和中优先级Electron邮件?

如果在 Laravel 5.1 中找不到路由,则显示 404 页面

如何在 laravel eloquent 中保存布尔值

如何从 PHPUnit 测试设置运行 Laravel 数据库 seeder 机?

你如何在 Laravel 5.3 的新通知服务生成的Electron邮件中添加图像?