-
-
Save ali-awwad/72c4af175822bcac9c80d10a7a9b7025 to your computer and use it in GitHub Desktop.
| # name this file as "startup.sh" and call it from "startup command" as "/home/startup.sh" | |
| # check out my YouTube video "https://youtu.be/-PGhVFsOnGA" | |
| cp /home/default /etc/nginx/sites-enabled/default | |
| cp /home/php.ini /usr/local/etc/php/conf.d/php.ini | |
| # install support for webp file conversion | |
| apt-get update --allow-releaseinfo-change && apt-get install -y libfreetype6-dev \ | |
| libjpeg62-turbo-dev \ | |
| libpng-dev \ | |
| libwebp-dev \ | |
| && docker-php-ext-configure gd --with-freetype --with-webp --with-jpeg | |
| docker-php-ext-install gd | |
| # install support for queue | |
| apt-get install -y supervisor | |
| cp /home/laravel-worker.conf /etc/supervisor/conf.d/laravel-worker.conf | |
| # restart nginx | |
| service nginx restart | |
| service supervisor restart | |
| php /home/site/wwwroot/artisan down --refresh=15 --secret="1630542a-246b-4b66-afa1-dd72a4c43515" | |
| php /home/site/wwwroot/artisan migrate --force | |
| # Clear caches | |
| php /home/site/wwwroot/artisan cache:clear | |
| # Clear expired password reset tokens | |
| #php /home/site/wwwroot/artisan auth:clear-resets | |
| # Clear and cache routes | |
| php /home/site/wwwroot/artisan route:cache | |
| # Clear and cache config | |
| php /home/site/wwwroot/artisan config:cache | |
| # Clear and cache views | |
| php /home/site/wwwroot/artisan view:cache | |
| # Install node modules | |
| # npm ci | |
| # Build assets using Laravel Mix | |
| # npm run production --silent | |
| # uncomment next line if you dont have S3 or Blob storage | |
| #php /home/site/wwwroot/artisan storage:link | |
| # Turn off maintenance mode | |
| php /home/site/wwwroot/artisan up | |
| # run worker | |
| nohup php /home/site/wwwroot/artisan queue:work & |
| process_name=%(program_name)s_%(process_num)02d | |
| command=php /home/site/wwwroot/artisan queue:work --sleep=3 --tries=3 --max-time=3600 | |
| autostart=true | |
| autorestart=true | |
| stopasgroup=true | |
| killasgroup=true | |
| user=forge | |
| numprocs=8 | |
| redirect_stderr=true | |
| stdout_logfile=/home/site/wwwroot/storage/logs/worker.log | |
| stopwaitsecs=3600 |
| # nginx default file, name it as "default" | |
| # check out my YouTube video "https://youtu.be/-PGhVFsOnGA" | |
| server { | |
| #proxy_cache cache; | |
| #proxy_cache_valid 200 1s; | |
| listen 8080; | |
| listen [::]:8080; | |
| root /home/site/wwwroot/public; | |
| server_name mywebapp.azurewebsites.net; | |
| port_in_redirect off; | |
| add_header X-Frame-Options "SAMEORIGIN"; | |
| add_header X-Content-Type-Options "nosniff"; | |
| index index.php; | |
| charset utf-8; | |
| if ($http_x_arr_ssl = "") { | |
| return 301 https://$host$request_uri; | |
| } | |
| location / { | |
| try_files $uri $uri/ /index.php?$query_string; | |
| } | |
| location = /favicon.ico { access_log off; log_not_found off; } | |
| location = /robots.txt { access_log off; log_not_found off; } | |
| error_page 404 /index.php; | |
| location ~ /\.(?!well-known).* { | |
| deny all; | |
| } | |
| # Add locations of phpmyadmin here. | |
| location ~ [^/]\.php(/|$) { | |
| fastcgi_split_path_info ^(.+?\.php)(|/.*)$; | |
| fastcgi_pass 127.0.0.1:9000; | |
| include fastcgi_params; | |
| fastcgi_param HTTP_PROXY ""; | |
| fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
| fastcgi_param PATH_INFO $fastcgi_path_info; | |
| fastcgi_param QUERY_STRING $query_string; | |
| fastcgi_intercept_errors on; | |
| fastcgi_connect_timeout 300; | |
| fastcgi_send_timeout 3600; | |
| fastcgi_read_timeout 3600; | |
| fastcgi_buffer_size 128k; | |
| fastcgi_buffers 4 256k; | |
| fastcgi_busy_buffers_size 256k; | |
| fastcgi_temp_file_write_size 256k; | |
| } | |
| } |
| error_log=/dev/stderr | |
| display_errors=Off | |
| log_errors=On | |
| display_startup_errors=Off | |
| date.timezone=Asia/Dubai | |
| memory_limit=256M |
This has both queue worker and
nohupto start the queue but do you need both?
With Azure WebApps, files stored outside the /home directory don't persist, so I don't believe the supervisor driven queue would work.
Thank you for providing these configuration.
I am using Azure Web app and I had to change couple lines in order for my app to work.
I commented the artisan queue line because Supervisor already takes care of it so we don't need it
laravel-on-azure-web-app-startup-command.sh
# run worker
# nohup php /home/site/wwwroot/artisan queue:work &
Also on Laravel worker config file, I added the first line because it was giving me the program_name error and also I commented the user because it couldn't find the user
laravel-worker.conf
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /home/site/wwwroot/artisan queue:work --sleep=3 --tries=3 --max-time=3600
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
;user=forge
numprocs=8
redirect_stderr=true
stdout_logfile=/home/site/wwwroot/storage/logs/worker.log
stopwaitsecs=3600
After these changes, it is working as expected with 8 workers
how increse size of files ? 413 Request Entity Too Large
This has both queue worker and
nohupto start the queue but do you need both?