deployphp / deployer

The PHP deployment tool with support for popular frameworks out of the box
https://deployer.org
MIT License
10.41k stars 1.47k forks source link

Downtime during deployment. Missing Composer autoload file. Failed to open stream: No such file or directory #3767

Open farrance opened 5 months ago

farrance commented 5 months ago

import:
  - recipe/deploy/cleanup.php
  - recipe/laravel.php
  - contrib/npm.php

config:
  keep_releases: 5
  application: '{My application name}'
  repository: '{My private repo}'
  base_deploy_path: '/var/www'
  remote_user: ubuntu
  identity_file: '{My key}'
  become: 'root'

hosts:
  production:
    deploy_path: '{{base_deploy_path}}/{My web site}'
    hostname: '{My IP}'
    port: {My port}

tasks:
  deploy:
    - deploy:prepare
    - deploy:vendors
    - deploy:unlock

after:
  deploy:failed:
    - deploy:unlock
  deploy:update_code:
    - npm:install
  npm:install:
    - npm:build

My project takes a few minutes to deploy. During this period the whole site goes down. I checked the Nginx error logs and it seems my autoload.php for Composer goes missing during the deployment. The deployment itself is successful and will come back online once completed.

2024/01/09 16:20:37 [error] 1217744#1217744: *201 FastCGI sent in stderr: "PHP message: PHP Warning: require(/var/www/{My web site}/releases/15/public/../vendor/autoload.php): Failed to open stream: No such file or directory in /var/www/{My web site}/releases/15/public/index.php on line 34PHP message: PHP Fatal error: Uncaught Error: Failed opening required '/var/www/{My web site}/releases/15/public/../vendor/autoload.php' (include_path='.:/usr/share/php') in /var/www/{My web site}/releases/15/public/index.php:34

Stack trace:
#0 {main}

thrown in /var/www/{My web site}/releases/15/public/index.php on line 34" while reading response header from upstream, client: 51.155.34.90, server: {Any sub domain}.{My web site}.net, request: "GET /{My web site}/{Any web page} HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php8.1-fpm.sock:", host: "{Any sub domain}.{My web site}.net", referrer: "{Any sub domain}.{My web site}.net"

{Curly brackets} omitted for sensitivity.

Upvote & Fund

Fund with Polar