我刚刚将自己的维护模式称为 ApplicationMaintenanceMode 扩展了 CheckForMaintenanceMode。
class ApplicationMaintenanceMode extends CheckForMaintenanceMode
{
....
}
并扩展应用程序类
use Illuminate\Foundation\Application as App;
class Application extends App
{
....
....
public function isApplicationDownForMaintenance()
{
//code
}
}
然后,我也像原来一样创建自己的 DownCommand
class DownCommand extends Command
{
protected $signature = 'app_down {--message= : The message for the maintenance mode. }
{--retry= : The number of seconds after which the request may be retried.}
{--only=* : Routes to be include from maintenance mode.}
{--type=* : Type of maintenance mode.}
{--except=* : Routes to be exclude from maintenance mode.}
{--version_allow= : Application Version allowed.}
{--lock_queue=false : Application Queue need to run or not.}
{--allow=* : IP or networks allowed to access the application while in maintenance mode.}';
}
正如你所看到的--lock_queue 我想在哪里切换队列工作者可以运行或不运行。目的是原来的维护模式,它停止所有的队列。我想要实现的是我希望队列可以在维护模式下轻松切换以运行或不运行。
有什么办法吗?我应该覆盖 QueueManager 和 Worker 类吗?