Docker deploys Laravel application to realize queue & task scheduling

Docker deploys Laravel application to realize queue & task scheduling

In the previous article, we wrote about how to deploy Laravel applications with Docker. In this article, we will write about how to deploy Laravel applications with queues and task scheduling.

1. Let's first prepare our docker/app.cron file

Note that the blank line at the end of the file is required.

#!/usr/bin/env bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
* * * * * cd /var/www/html && php artisan schedule:run >> /dev/null 2>&1

2. Create a new entry file: docker-entrypoint-queue.sh

Note that this file requires execute permissions.

#!/usr/bin/env bash

php artisan cache:clear
php artisan config:cache
php artisan route:cache
php artisan view:cache

# Load the scheduled task and restart cron
crontab docker/app.cron
/etc/init.d/cron restart

# Execute queue php artisan queue:work --timeout=60

3. This time we use docker compose to run the program: ./docker-compose.yml

version: "3.4"

services:
 API:
  build: .
  image: moorper/example-laravel
  networks:
   -frontend
   - backend
  environment:
   - APP_ENV=development
  ports:
   - "80:80"
  entrypoint: ./docker-entrypoint.sh
 queue:
  build: .
  image: moorper/example-laravel
  networks:
   - backend
  environment:
   - APP_ENV=development
  entrypoint: ./docker-script-entrypoint.sh
  
networks:
 frontend:
 backend:

4. Operation

docker-compose up -d

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Laravel5.6 framework mail queue database driver simple demo example
  • Summary of Laravel's Queue Queue Tips
  • Laravel 6 will add the ability to set middleware for specific queue tasks
  • Implementation of Laravel Queue
  • Analysis of the principle and usage of Laravel framework queue
  • Why not use blpop to get the queue in Laravel?
  • Detailed explanation of the problem of multiple processes in Laravel Redis taking queues at the same time
  • Source code analysis of the reasons why Laravel repeatedly executes the same queue task
  • Some issues that need to be paid attention to when using message queues in Laravel
  • Example of sending emails using queues in Laravel
  • A brief discussion on the implementation principle of Laravel queue and problem solving records
  • A brief analysis of the configuration and use of queues in Laravel5
  • How to use message queues and asynchronous queues in PHP's Laravel framework
  • Experience using queue service in Laravel 4.2
  • Detailed explanation of queue and job operations in Laravel framework

<<:  MySQL 5.7.20 installation and configuration method graphic tutorial (win10)

>>:  Vue recursively implements three-level menu

Recommend

Example code for Html layered box-shadow effect

First, let’s take a look at the picture: Today we...

Share some uncommon but useful JS techniques

Preface Programming languages ​​usually contain v...

Native JS realizes uniform motion of various sports

This article shares with you a uniform motion imp...

Problems and solutions when installing and using VMware

The virtual machine is in use or cannot be connec...

Centos8 builds nfs based on kdc encryption

Table of contents Configuration nfs server (nfs.s...

Get the IP and host name of all hosts on Zabbix

zabbix Zabbix ([`zæbiks]) is an enterprise-level ...

Solution to MySQL Installer is running in Community mode

Today I found this prompt when I was running and ...

Detailed explanation of the command mode in Javascript practice

Table of contents definition structure Examples C...

Analysis of the Principles of MySQL Slow Query Related Parameters

MySQL slow query, whose full name is slow query l...

Tutorial on installing MYSQL8.X on Centos

MySQL installation (4, 5, 6 can be omitted) State...

Detailed explanation of using JavaScript WeakMap

A WeakMap object is a collection of key/value pai...

Detailed explanation of Linux inotify real-time backup implementation method

Real-time replication is the most important way t...

Mysql master/slave database synchronization configuration and common errors

As the number of visits increases, for some time-...

How to set up automatic daily database backup in Linux

This article takes Centos7.6 system and Oracle11g...

Ubuntu 15.04 opens mysql remote port 3306

Ubuntu 15.04 opens MySQL remote port 3306. All th...