簡體   English   中英

如何在 Elastic Beanstalk 上運行 Laravel 數據庫隊列?

[英]How do I run a Laravel database queue on Elastic Beanstalk?

I am new to AWS EB but was able to set up a PHP 8.0 running on 64bit Amazon Linux 2/3.3.9 Laravel API.

我在數據庫隊列中有一些作業,我想使用php artisan queue:listen運行。 我關注了這個Stack Exchange 問題,但是當我推送我的代碼時,腳本沒有運行,因為作業沒有執行

我可以手動將 SSH 放入 EC2 實例中,並使用這個問題/opt/elasticbeanstalk/deployment/env中手動設置 env 變量。 然后,當我運行php artisan queue:listen時,它可以工作!

如何設置我的腳本,以便它們在 EC2/EB 實例啟動並且隊列上的作業運行時運行?

PS:我的環境配置工作正常,數據庫配置工作正常

這是我當前的腳本設置:

./.ebextensions/01-setup.config

 container_commands: 01-no_dev: command: "composer.phar install --optimize-autoloader --no-dev" 02-config_clear: command: "php artisan config:clear" 03-view_clear: command: "php artisan view:clear" 04-route_cache: command: "php artisan route:cache" 05-view_cache: command: "php artisan view:cache" 06-migrate: command: "php artisan migrate --force" leader_only: true 07-queue_service_restart: command: "systemctl restart laravel_worker" files: /opt/elasticbeanstalk/tasks/taillogs.d/laravel-logs.conf: content: /var/app/current/storage/logs/laravel.log group: root mode: "000755" owner: root /etc/systemd/system/laravel_worker.service: mode: "000755" owner: root group: root content: | # Laravel queue worker using systemd # ---------------------------------- # # /lib/systemd/system/queue.service # # run this command to enable service: # systemctl enable queue.service [Unit] Description=Laravel queue worker [Service] User=nginx Group=nginx Restart=always ExecStart=/usr/bin/nohup /usr/bin/php /var/www/html/artisan queue:work //is this line correct??? [Install] WantedBy=multi-user.target

\.platform\nginx\conf.d\elasticbeanstalk\laravel.conf

 location / { try_files $uri $uri/ /index.php?$query_string; gzip_static on; }

./.ebextensions/cron-linux.config

 files: "/etc/cron.d/schedule_run": mode: "000644" owner: root group: root content: | * * * * * root. /opt/elasticbeanstalk/deployment/env && /usr/bin/php /var/app/current/artisan schedule:run 1>> /dev/null 2>&1 commands: remove_old_cron: command: "rm -f /etc/cron.d/*.bak"

如果您的腳本/應用程序依賴於不是 in.env 但作為 os 環境變量加載的變量,則默認情況下您的 cron 將無法訪問它們。

除非您在啟動 cron 之前使用以下命令導出: env >> /etc/environment

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM