尊龙凯时人生就是博

laravelÐÐÁÐÔõÑùÒ»Ö±Ö´ÐÐ

ÔÚʹÓà laravel µÄ¿ª·¢ÖУ¬ÐÐÁо­³£ÊDZز»¿ÉÉÙµÄÒ»²¿·Ö ¡£ËüÄܹ»¼«´óµÄÌá¸ßÓ¦ÓóÌÐòµÄ²¢·¢´¦ÀíÄÜÁ¦£¬Èôó×ÚµÄʹÃüÄܹ»»ñµÃÓÐÓõÄÖÎÀíºÍ´¦Àí ¡£¿ÉÊÇÔÚÏÖʵ¿ª·¢ÖУ¬ÎÒÃǾ­³£»áÓöµ½ÕâÑùÒ»¸öÎÊÌ⣺ÐÐÁв»ÎȹÌ£¬Ê¹Ãü¶àʱÐÐÁÐͻȻ×èÖ¹ÁË£¬»òÕßʹÃü·ºÆðÒ쳣ʱÐÐÁÐÒ²ÎÞ·¨×Ô¶¯ÖØÆô ¡£ÕâʱÎÒÃǾÍÐèҪһЩ¼¼ÇÉ£¬ÈÃÐÐÁÐÄܹ»Îȹ̵ÄÔËÐÐÏÂÈ¥ ¡£ÏÂÃæ¾ÍÏÈÈݼ¸ÖÖÒªÁ죬×ÊÖú¸÷È˽â¾öÕâЩÎÊÌâ ¡£

Ò»¡¢supervisor ÊØ»¤Àú³Ì

supervisor ÊÇÒ»¿îÓà Python дµÄÀú³Ì¿ØÖÆϵͳ£¬ÊÇ Linux ЧÀÍÆ÷ÉÏÖÎÀíÀú³ÌµÄÒ»ÖÖ³£¼ûµÄ¹¤¾ß£¬¿ÉÒÔ×ÊÖúÎÒÃÇÔÚºǫ́һֱµÄ¼à¿ØÒ»¸öÀú³Ì£¬ÈôÊÇÕâ¸öÀú³ÌÒòijÖÖÔµ¹ÊÔ­ÓÉÍ˳öÁË£¬ÄÇôËüÄܹ»Ëæ×ÅËÞÖ÷Àú³ÌÖØÐÂÆô¶¯ ¡£Õâ¾ÍÄÜ°ü¹ÜÄãµÄÐÐÁÐÒ»Ö±Äܹ»ÔËÐÐÏÂÈ¥ ¡£

×°ÖÃ supervisor

Centos ϵͳִÐÐ

yum install -y supervisor

Ubuntu ϵͳִÐÐ

apt-get install -y supervisor

·­¿ªÉèÖÃÎļþ

vim /etc/supervisord.conf

¼ÓÈëÎÒÃÇµÄ laravel-queue ÉèÖýÚ

[program:laravel-queue]

command=php /path/to/artisan queue:work redis –sleep=3 –tries=3

directory=/path/to/your/project

autostart=true

autorestart=true

user=www-data

˵Ã÷£º

program£º½ç˵Àú³ÌµÄÃû³Æ

command£º½ç˵ÔËÐÐÏÂÁî

autostart£º¿ª»ú×ÔÆô¶¯

autorestart£º×Ô¶¯ÖØÆô

user£ºÔËÐÐÀú³ÌµÄÓû§

ÉúÑÄÐ޸ĺó¼ÓÔØÉèÖÃ

supervisorctl reload

Æô¶¯ÐÐÁÐ

supervisorctl start laravel-queue

ÕâÑù¾Í¿ÉÒÔʵÏÖ¶ÔÐÐÁеÄÊØ»¤Àú³ÌÁË ¡£ÈôÊÇÐÐÁÐ×èÖ¹ÁË£¬Õâ¸öÀú³Ì¾Í»á×Ô¶¯ÖØÆô£¬´Ó¶ø°ü¹ÜÐÐÁÐÒ»Ö±ÔÚÔËÐÐ ¡£ËäÈ»£¬ÉèÖÃÎļþÖÐÒ²¿ÉÒÔͨ¹ýÉèÖÃÔËÐжà¸ö work Àú³Ì£¬Ìá¸ßÐÐÁд¦ÀíÄÜÁ¦ ¡£

¶þ¡¢Ê¹Óà Hashicorp µÄ Nomad ¼¯³É Marathon

Hashicorp µÄ Nomad Óë Marathon ²Ù×÷ÀàËÆ£¬ËüÃǶ¼ÊÇÓÃÓÚÂþÑÜʽʹÃü±àÅŵÄÒ»¿î¿ªÔ´µÄ¹¤¾ß ¡£Nomad ͨ¹ýÁýͳ»¯Ê¹ÃüµÄλÖú;öÒ飬Äܹ»¶ÔÒ»×é²î±ðÀàÐ͵ÄʹÃü¾ÙÐбàÅÅ ¡£Nomad Óë Marathon Ïà±È¾ßÓÐÇáÁ¿¡¢Óû§ÌåÑé¶È¸ß¡¢Ò×ÓÚÉèÖõÄÓÅÊÆ ¡£

ʹÓà Nomad ÐèÒª docker ÇéÐΣ¬ÈôÊÇÄãûÓÐ×°Öà docker£¬¿ÉÒÔÏÈͨ¹ý apt-get ×°Öãº

apt-get install -y docker.io

½¨Éè Nomad Job

ÔÚÏîÄ¿¸ùĿ¼Ï½¨Éè job.nomad Îļþ£¬Í¨¹ýÉèÖý¨ÉèÒ»¸ö Nomad Job£º

job “laravel_app” {

datacenters = [“dc1”]

type = “service”

group “app” {

task "laravel-queue" {
  driver = "docker"

  config {
    image = "your_docker_image"
    command = ["php", "artisan", "queue:work", "--tries", "1", "--timeout", "30"]
    args = [
      "--queue=critical,high,default,email,chat,sms",
      "--sleep=3"
    ]
    ports = ["http"]
  }

  resources {
    cpu    = 500
    memory = 128
    network {
      mbits = 10
      port "http" {}
    }
  }

  service {
    name = "laravel-queue"
    port = "http"
    check {
      type     = "http"
      path     = "/status"
      interval = "10s"
      timeout  = "2s"
    }
  }

  restart {
    attempts = 10
    interval = "5m"
    delay    = "25s"
    mode     = "failures"
  }
}

µÇ¼ºó¸´ÖÆ

}

}

ÒÔÉϵÄÉèÖÃÎļþÔÚµ¥»úģʽÏÂʹÓõÄÊÇ docker ÔËÐУ¬ÔÚÉú²úÇéÐÎÏÂƾ֤ÏÖÕæÏàÐξÙÐÐÐÞ¸Ä ¡£

Æô¶¯ Nomad Job

Ö´ÐÐÒÔÏÂÏÂÁÆô¶¯ Nomad Job£º

nomad run job.nomad

ÖÁ´Ë¾ÍÍê³ÉÁËÐÐÁеÄÆô¶¯ ¡£Nomad »áÔÚÒ»¸ö½ÚµãÉÏÔËÐÐÎÒÃÇµÄ Job£¬Í¬Ê±¿ÉÒԶԸà Job ¾ÙÐмà¿Ø£»µ±Ê¹Ãü·ºÆðÎÊÌ⣬Nomad ¿ÉÒÔ¿ìËÙµÄÖØÆôʹÃü²¢¸üÐÂ״̬ ¡£Nomad Job ¿ÉÒÔÔÚ¼¯ÈºÖеIJî±ð½Úµã¼ä×Ô¶¯Ç¨á㣬ÕâÑù¿ÉÒÔ¼õÇáij¸ö½ÚµãµÄ¸ºÔØ£¬Ìá¸ßÁË×ÜÌåÓ¦ÓóÌÐòµÄµÄ³°ôÐÔ ¡£

Èý¡¢Ê¹Óà AWS SQS

AWS µÄ SQS£¨Simple Queue Service£©ÊÇÒ»¿îÓÃÓÚÐÂÎÅÐÐÁеÄЧÀÍ£¬Ëü¿ÉÒÔÔÚÂþÑÜʽӦÓóÌÐòÖ®¼ä¸ßЧµØת´ïºÍ´¦ÀíÐÂÎÅ£¬²¢ÔÊÐíÓ¦ÓóÌÐòÖ®¼äµÄÐÂÎÅ´¦ÀíÄÜÁ¦ÊµÏÖˮƽÉìËõ ¡£ÔÚ Laravel ¿ò¼ÜÖУ¬SQS ¿ÉÒÔºÜÊÇÀû±ãµØ¼¯³Éµ½ÎÒÃǵÄÓ¦ÓóÌÐòÖУ¬Ö»ÐèҪװÖÃÖ§³Ö SQS µÄ Laravel Queue °ü¼´¿É ¡£Í¬Ê±£¬ÔÚ AWS µÄ SQS ÖУ¬Ã¿Ò»¸öÐÐÁж¼ÓÐÒ»¸ö×îС¿ÉÉúÃüÖÜÆÚ£¨TTL£©£¬ÈôÊÇÔÚ¸Ãʱ¼ä¶ÎÄÚδ±»Ö´ÐÐÀֳɣ¬Ôò¸ÃʹÃü»á±» SQS ɾµô ¡£ÕâÑù¿ÉÒÔ°ü¹ÜÒ»¸öʹÃü×îÖÕÒ»¶¨»á±»Ö´ÐÐÀÖ³É ¡£

×°ÖÃ SQS

ÔÚ Laravel Öм¯³É SQS Ïà¶Ô½ÏÁ¿¼òÆÓ£¬Ö»ÐèҪװÖÃÖ§³Ö SQS µÄ Laravel Queue °ü¼´¿É ¡£¿ÉÒÔÖ±½Óͨ¹ý Composer ×°Öãº

composer require “aws/aws-sdk-php ^3.0”

ÉèÖÃ SQS

ÔÚ .env ÉèÖÃÎļþÖÐÌí¼ÓÒÔÏÂÄÚÈÝ£º

QUEUE_DRIVER=sqs

AWS_ACCESS_KEY_ID=your_aws_access_key

AWS_SECRET_ACCESS_KEY=your_aws_secret_key

AWS_DEFAULT_REGION=us-west-2

SQS_PREFIX=your_queue_prefix

Ìæ»» your_aws_access_key¡¢your_aws_secret_key ºÍ your_queue_prefix ΪÄã×Ô¼ºµÄ ¡£

Æô¶¯ÐÐÁÐ

php artisan queue:work sqs –queue=default –tries=3 –sleep=3 –timeout=60

ÒÔÉÏÏÂÁî»áÆô¶¯Ò»¸ö SQS ÐÐÁУ¬²¢Ê¹ÓÃĬÈ쵀 default ÐÐÁУ¬ÆäÖÐ –tries ²ÎÊýÌåÏÖÐÐÁÐʹÃüÍÉ»¯ÊµÑéµÄ´ÎÊý£¬–sleep ÌåÏÖÐÐÁд¦ÀíÍêʹÃüÐÝÏ¢µÄʱ¼ä£¬–timeout ÌåÏÖÐÐÁÐʹÃü³¬Ê±Ê±µÄ×Ô¶¯ÖØÊÔʱ¼ä ¡£ÐÐÁлáһֱѭ»·»ñȡʹÃü²¢Ö´ÐУº

·ºÆð¹ýʧʱ£¬ÐÐÁлá×Ô¶¯ÖØÊÔ£¬Ö±ÖÁÐÐÁÐʹÃüÍÉ»¯ÊµÑéµÄ´ÎÊýÓÃÍê»òÕßÖ´ÐÐÀÖ³ÉΪֹ ¡£

×ܽá

ÔÚ±¾ÎÄÖУ¬ÎÒÃÇÏÈÈÝÁ˼¸ÖÖÈà Laravel ÐÐÁÐÒ»Ö±Ö´ÐеÄÒªÁ죬ͨ¹ýÊØ»¤Àú³Ì¡¢Ê¹Ãü±àÅÅ¡¢µÚÈý·½Ð§À͵ȷ½·¨£¬¿ÉÒÔΪÐÐÁÐÌṩԽ·¢Îȹ̡¢¸ßЧµÄÔËÐÐÖ§³Ö ¡£Ã¿ÖÖÒªÁ춼Óи÷×ÔµÄÓŵãºÍÊÊÓùæÄ££¬ÏêϸѡÔñÄÄÒ»ÖÖÒªÁ죬ÐèҪƾ֤×Ô¼ºµÄÏÖÕæÏàÐÎÀ´×ö³ö¾öÒé ¡£

ÒÔÉϾÍÊÇlaravelÐÐÁÐÔõÑùÒ»Ö±Ö´ÐеÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是博ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼ ¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是博ʵʱÐÞÕý»òɾ³ý ¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是博

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ