简体   繁体   English

在LAMP堆栈中运行后台进程

[英]Running background process in LAMP stack

I have an application running on LAMP stack.In USER model after expiration of subscription deadline,I need to set user's current 我有一个在LAMP堆栈上运行的应用程序。在订阅截止日期到期后的USER模型中,我需要设置用户的当前

subscription to default or free subscription. 订阅默认或免费订阅。

So I need a background process which always checks for the expiration of user's subscription deadline and set to default subscription. 因此,我需要一个后台进程,该进程始终检查用户的订阅期限是否已到期并将其设置为默认订阅。

Is there any other efficient and manageable solution to run a background process which will update user's data ? 是否有其他有效且可管理的解决方案来运行将更新用户数据的后台进程?

Application Environment: 应用环境:

CakePHP,Redis,MariaDB CakePHP,Redis,MariaDB

Please edit if this question isn't good enough to describe my problem :( 如果这个问题不足以描述我的问题,请编辑:(

So in general your question about recurring event, if this event do changes in DB and also another actions like send emails or stop some services or connect to remote resource,, you have to use cron job 因此,通常来说,您对重复事件的问题是,如果此事件确实在数据库中发生更改,并且还发生了其他操作(如发送电子邮件或停止某些服务或连接到远程资源),则必须使用cron作业

but if this event only related to DB then you can create recurring event like the following link 但是,如果此事件仅与数据库有关,则可以创建重复事件,例如以下链接

In case of PHP there is not so many out-of-the-box solutions. 对于PHP,没有很多现成的解决方案。 One of the available is rabbitmq-delayed-sample . 可用的一种是Rabbitmq-delayed-sample It is built on top of rabbitmq messaging system. 它建立在rabbitmq消息传递系统之上。

Usage example: 用法示例:

$container->get('delayed_producer')->delayedPublish(5000, $messageBody, '');

where 5000 is an expiration period after that job will be executed. 其中5000是执行该作业后的到期期限。 You can put such code to the new user creation place. 您可以将这样的代码放入新的用户创建位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM