deployphp / deployer

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

Lumen 5.8 deployment failed – no commands defined in the "storage" namespace #1856

Closed iamphilrae closed 5 years ago

iamphilrae commented 5 years ago
Q A
Issue Type Bug
Deployer Version 6.4.3
Local Machine OS MacOS Mojave
Remote Machine OS Ubuntu 18.04.2 LTS

Description

Attempting to deploy a Lumen project to an Ubuntu AWS EC2 server. The process begins however halts mid-way with this error logged by Lumen.

Symfony\Component\Console\Exception\NamespaceNotFoundException: There are no commands defined in the "storage" namespace. in /var/www/service1/releases/1/vendor/symfony/console/Application.php:589 
Stack trace: 
#0 /var/www/service1/releases/1/vendor/symfony/console/Application.php(638): Symfony\Component\Console\Application->findNamespace('storage') 
#1 /var/www/service1/releases/1/vendor/symfony/console/Application.php(237): Symfony\Component\Console\Application->find('storage:link') 
#2 /var/www/service1/releases/1/vendor/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) 
#3 /var/www/service1/releases/1/vendor/illuminate/console/Application.php(90): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) 
#4 /var/www/service1/releases/1/vendor/laravel/lumen-framework/src/Console/Kernel.php(115): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) 
#5 /var/www/service1/releases/1/artisan(35): Laravel\Lumen\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) 
#6 {main} {"exception":"[object] (Symfony\\Component\\Console\\Exception\\NamespaceNotFoundException(code: 0): There are no commands defined in the \"storage\" namespace. at /var/www/service1/releases/1/vendor/symfony/console/Application.php:589)"} []

Steps to reproduce

Content of deploy.php

<?php
namespace Deployer;

require 'recipe/laravel.php';

// Project name
set('application', 'service-website-crawler');

// Project repository
set('repository', 'git@bitbucket.org:xxxxxxxxxxx/xxxxxxxxxxxx.git');

// [Optional] Allocate tty for git clone. Default value is false.
set('git_tty', true);

// Shared files/dirs between deploys
add('shared_files', []);
add('shared_dirs', []);

// Writable dirs by web server
add('writable_dirs', []);

// Hosts

host('xxxxxx@xxxxxxxxxxxxxxx.com')
    ->set('deploy_path', '/var/www/service1');

// Tasks

task('build', function () {
    run('cd {{release_path}} && build');
});

// [Optional] if deploy fails automatically unlock.
after('deploy:failed', 'deploy:unlock');

// Migrate database before symlink new release.

before('deploy:symlink', 'artisan:migrate');

Output log

[localhost] > git rev-parse --abbrev-ref HEAD
[localhost] < master
✈︎ Deploying master on xxxxxxx@xxxxxxxxxxxxx.com
• done on [xxxxxxx@xxxxxxxxxxxxx.com]
➤ Executing task deploy:prepare
[xxxxxxx@xxxxxxxxxxxxx.com] > echo $0
[xxxxxxx@xxxxxxxxxxxxx.com] < ssh multiplexing initialization
[xxxxxxx@xxxxxxxxxxxxx.com] < Welcome to Ubuntu 18.04.2 LTS (GNU/Linux 4.15.0-1039-aws x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Wed Jun  5 16:51:22 UTC 2019

  System load:  0.0               Processes:           111
  Usage of /:   8.0% of 29.02GB   Users logged in:     1
  Memory usage: 25%               IP address for eth0: 10.0.0.170
  Swap usage:   0%

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

 * Canonical Livepatch is available for installation.
   - Reduce system reboots and improve kernel security. Activate at:
     https://ubuntu.com/livepatch

8 packages can be updated.
1 update is a security update.

[xxxxxxx@xxxxxxxxxxxxx.com] < bash
[xxxxxxx@xxxxxxxxxxxxx.com] > if [ ! -d /var/www/service1 ]; then mkdir -p /var/www/service1; fi
[xxxxxxx@xxxxxxxxxxxxx.com] > if [ ! -L /var/www/service1/current ] && [ -d /var/www/service1/current ]; then echo 'true'; fi
[xxxxxxx@xxxxxxxxxxxxx.com] > cd /var/www/service1 && if [ ! -d .dep ]; then mkdir .dep; fi
[xxxxxxx@xxxxxxxxxxxxx.com] > cd /var/www/service1 && if [ ! -d releases ]; then mkdir releases; fi
[xxxxxxx@xxxxxxxxxxxxx.com] > cd /var/www/service1 && if [ ! -d shared ]; then mkdir shared; fi
• done on [xxxxxxx@xxxxxxxxxxxxx.com]
✔ Ok [1s 246ms]
➤ Executing task deploy:lock
[xxxxxxx@xxxxxxxxxxxxx.com] > if [ -f /var/www/service1/.dep/deploy.lock ]; then echo 'true'; fi
[xxxxxxx@xxxxxxxxxxxxx.com] > touch /var/www/service1/.dep/deploy.lock
• done on [xxxxxxx@xxxxxxxxxxxxx.com]
✔ Ok [156ms]
➤ Executing task deploy:release
[xxxxxxx@xxxxxxxxxxxxx.com] > cd /var/www/service1 && (if [ -h release ]; then echo 'true'; fi)
[xxxxxxx@xxxxxxxxxxxxx.com] < true
[xxxxxxx@xxxxxxxxxxxxx.com] > cd /var/www/service1 && (rm -rf "$(readlink release)")
[xxxxxxx@xxxxxxxxxxxxx.com] > cd /var/www/service1 && (rm release)
[xxxxxxx@xxxxxxxxxxxxx.com] > cd /var/www/service1 && (if [ -d releases ] && [ "$(ls -A releases)" ]; then echo 'true'; fi)
[xxxxxxx@xxxxxxxxxxxxx.com] > cd /var/www/service1 && (if [ -d /var/www/service1/releases/1 ]; then echo 'true'; fi)
[xxxxxxx@xxxxxxxxxxxxx.com] > cd /var/www/service1 && (date +"%Y%m%d%H%M%S")
[xxxxxxx@xxxxxxxxxxxxx.com] < 20190605165124
[xxxxxxx@xxxxxxxxxxxxx.com] > cd /var/www/service1 && (echo '20190605165124,1' >> .dep/releases)
[xxxxxxx@xxxxxxxxxxxxx.com] > cd /var/www/service1 && (mkdir /var/www/service1/releases/1)
[xxxxxxx@xxxxxxxxxxxxx.com] > cd /var/www/service1 && (if [[ $(man ln 2>&1 || ln -h 2>&1 || ln --help 2>&1) =~ '--relative' ]]; then echo 'true'; fi)
[xxxxxxx@xxxxxxxxxxxxx.com] < true
[xxxxxxx@xxxxxxxxxxxxx.com] > cd /var/www/service1 && (ln -nfs --relative /var/www/service1/releases/1 /var/www/service1/release)
• done on [xxxxxxx@xxxxxxxxxxxxx.com]
✔ Ok [1s 75ms]
➤ Executing task deploy:update_code
[xxxxxxx@xxxxxxxxxxxxx.com] > command -v 'git' || which 'git' || type -p 'git'
[xxxxxxx@xxxxxxxxxxxxx.com] < /usr/bin/git
[xxxxxxx@xxxxxxxxxxxxx.com] > /usr/bin/git version
[xxxxxxx@xxxxxxxxxxxxx.com] < git version 2.17.1
[xxxxxxx@xxxxxxxxxxxxx.com] > cd /var/www/service1 && (if [ -h /var/www/service1/release ]; then echo 'true'; fi)
[xxxxxxx@xxxxxxxxxxxxx.com] < true
[xxxxxxx@xxxxxxxxxxxxx.com] > cd /var/www/service1 && (readlink /var/www/service1/release)
[xxxxxxx@xxxxxxxxxxxxx.com] < releases/1
[xxxxxxx@xxxxxxxxxxxxx.com] > cd /var/www/service1 && (/usr/bin/git clone -b master  --recursive  git@bitbucket.org:europeancannabisholdings/service-business-wire-crawler.git /var/www/service1/releases/1 2>&1)
Cloning into '/var/www/service1/releases/1'...
remote: Counting objects: 171, done.
remote: Compressing objects: 100% (150/150), done.
remote: Total 171 (delta 55), reused 0 (delta 0)
Receiving objects: 100% (171/171), 38.32 KiB | 306.00 KiB/s, done.
Resolving deltas: 100% (55/55), done.
Connection to service-business-wire-crawler.brainofcannabis.com closed.
• done on [xxxxxxx@xxxxxxxxxxxxx.com]
✔ Ok [7s 328ms]
➤ Executing task deploy:shared
[xxxxxxx@xxxxxxxxxxxxx.com] > if [ -d /var/www/service1/shared/storage ]; then echo 'true'; fi
[xxxxxxx@xxxxxxxxxxxxx.com] < true
[xxxxxxx@xxxxxxxxxxxxx.com] > rm -rf /var/www/service1/releases/1/storage
[xxxxxxx@xxxxxxxxxxxxx.com] > mkdir -p `dirname /var/www/service1/releases/1/storage`
[xxxxxxx@xxxxxxxxxxxxx.com] > ln -nfs --relative /var/www/service1/shared/storage /var/www/service1/releases/1/storage
[xxxxxxx@xxxxxxxxxxxxx.com] > mkdir -p /var/www/service1/shared/.
[xxxxxxx@xxxxxxxxxxxxx.com] > if [ -f /var/www/service1/shared/.env ]; then echo 'true'; fi
[xxxxxxx@xxxxxxxxxxxxx.com] < true
[xxxxxxx@xxxxxxxxxxxxx.com] > if [ -f $(echo /var/www/service1/releases/1/.env) ]; then rm -rf /var/www/service1/releases/1/.env; fi
[xxxxxxx@xxxxxxxxxxxxx.com] > if [ ! -d $(echo /var/www/service1/releases/1/.) ]; then mkdir -p /var/www/service1/releases/1/.;fi
[xxxxxxx@xxxxxxxxxxxxx.com] > touch /var/www/service1/shared/.env
[xxxxxxx@xxxxxxxxxxxxx.com] > ln -nfs --relative /var/www/service1/shared/.env /var/www/service1/releases/1/.env
• done on [xxxxxxx@xxxxxxxxxxxxx.com]
✔ Ok [631ms]
➤ Executing task deploy:vendors
[xxxxxxx@xxxxxxxxxxxxx.com] > if hash unzip 2>/dev/null; then echo 'true'; fi
To speed up composer installation setup "unzip" command with PHP zip extension https://goo.gl/sxzFcD
[xxxxxxx@xxxxxxxxxxxxx.com] > if hash composer 2>/dev/null; then echo 'true'; fi
[xxxxxxx@xxxxxxxxxxxxx.com] > command -v 'php' || which 'php' || type -p 'php'
[xxxxxxx@xxxxxxxxxxxxx.com] < /usr/bin/php
[xxxxxxx@xxxxxxxxxxxxx.com] > cd /var/www/service1/releases/1 && curl -sS https://getcomposer.org/installer | /usr/bin/php
[xxxxxxx@xxxxxxxxxxxxx.com] < All settings correct for using Composer
[xxxxxxx@xxxxxxxxxxxxx.com] < Downloading...
[xxxxxxx@xxxxxxxxxxxxx.com] < Composer (version 1.8.5) successfully installed to: /var/www/service1/releases/1/composer.phar
[xxxxxxx@xxxxxxxxxxxxx.com] < Use it: php composer.phar
[xxxxxxx@xxxxxxxxxxxxx.com] > cd /var/www/service1/releases/1 && /usr/bin/php /var/www/service1/releases/1/composer.phar install --verbose --prefer-dist --no-progress --no-interaction --no-dev --optimize-autoloader
[xxxxxxx@xxxxxxxxxxxxx.com] < Loading composer repositories with package information
[xxxxxxx@xxxxxxxxxxxxx.com] < Updating dependencies
[xxxxxxx@xxxxxxxxxxxxx.com] < Dependency resolution completed in 0.128 seconds
[xxxxxxx@xxxxxxxxxxxxx.com] < Analyzed 15408 packages to resolve dependencies
[xxxxxxx@xxxxxxxxxxxxx.com] < Analyzed 111920 rules to resolve dependencies
[xxxxxxx@xxxxxxxxxxxxx.com] < Dependency resolution completed in 0.000 seconds
[xxxxxxx@xxxxxxxxxxxxx.com] < Package operations: 60 installs, 0 updates, 0 removals
[xxxxxxx@xxxxxxxxxxxxx.com] < Installs: doctrine/event-manager:v1.0.0, doctrine/cache:v1.8.0, doctrine/dbal:v2.9.2, symfony/polyfill-ctype:v1.11.0, phpoption/phpoption:1.5.0, vlucas/phpdotenv:v3.3.3, symfony/polyfill-php72:v1.11.0, symfony/polyfill-mbstring:v1.11.0, symfony/var-dumper:v4.3.0, symfony/polyfill-intl-idn:v1.11.0, symfony/mime:v4.3.0, symfony/http-foundation:v4.3.0, psr/log:1.1.0, symfony/polyfill-php73:v1.11.0, symfony/debug:v4.3.0, symfony/event-dispatcher-contracts:v1.1.1, symfony/event-dispatcher:v4.3.0, symfony/http-kernel:v4.3.0, nikic/fast-route:v1.3.0, dragonmantank/cron-expression:v2.3.0, symfony/finder:v4.3.0, symfony/service-contracts:v1.1.2, symfony/console:v4.3.0, monolog/monolog:1.24.0, symfony/translation-contracts:v1.1.2, symfony/translation:v4.3.0, nesbot/carbon:2.19.1, psr/simple-cache:1.0.1, psr/container:1.0.0, illuminate/contracts:v5.8.20, doctrine/inflector:v1.3.0, illuminate/support:v5.8.20, illuminate/log:v5.8.20, illuminate/filesystem:v5.8.20, illuminate/container:v5.8.20, illuminate/events:v5.8.20, illuminate/view:v5.8.20, illuminate/translation:v5.8.20, doctrine/lexer:v1.0.1, egulias/email-validator:2.1.8, illuminate/validation:v5.8.20, symfony/process:v4.3.0, opis/closure:3.3.0, illuminate/database:v5.8.20, illuminate/console:v5.8.20, illuminate/queue:v5.8.20, illuminate/pipeline:v5.8.20, illuminate/pagination:v5.8.20, illuminate/session:v5.8.20, illuminate/http:v5.8.20, illuminate/hashing:v5.8.20, illuminate/encryption:v5.8.20, illuminate/config:v5.8.20, illuminate/cache:v5.8.20, illuminate/bus:v5.8.20, illuminate/broadcasting:v5.8.20, illuminate/auth:v5.8.20, laravel/lumen-framework:v5.8.8, paquettg/string-encode:1.0.1, paquettg/php-html-parser:2.0.2
[xxxxxxx@xxxxxxxxxxxxx.com] < As there is no 'unzip' command installed zip files are being unpacked using the PHP zip extension.
[xxxxxxx@xxxxxxxxxxxxx.com] < This may cause invalid reports of corrupted archives. Besides, any UNIX permissions (e.g. executable) defined in the archives will be lost.
[xxxxxxx@xxxxxxxxxxxxx.com] < Installing 'unzip' may remediate them.
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing doctrine/event-manager (v1.0.0): Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing doctrine/cache (v1.8.0): Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing doctrine/dbal (v2.9.2):
[xxxxxxx@xxxxxxxxxxxxx.com] < Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing symfony/polyfill-ctype (v1.11.0): Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing phpoption/phpoption (1.5.0): Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing vlucas/phpdotenv (v3.3.3): Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing symfony/polyfill-php72 (v1.11.0): Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing symfony/polyfill-mbstring (v1.11.0): Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing symfony/var-dumper (v4.3.0): Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing symfony/polyfill-intl-idn (v1.11.0): Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing symfony/mime (v4.3.0): Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing symfony/http-foundation (v4.3.0):
[xxxxxxx@xxxxxxxxxxxxx.com] < Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing psr/log (1.1.0):
[xxxxxxx@xxxxxxxxxxxxx.com] < Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing symfony/polyfill-php73 (v1.11.0): Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing symfony/debug (v4.3.0): Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing symfony/event-dispatcher-contracts (v1.1.1): Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing symfony/event-dispatcher (v4.3.0): Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing symfony/http-kernel (v4.3.0):
[xxxxxxx@xxxxxxxxxxxxx.com] < Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing nikic/fast-route (v1.3.0): Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing dragonmantank/cron-expression (v2.3.0): Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing symfony/finder (v4.3.0): Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing symfony/service-contracts (v1.1.2): Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing symfony/console (v4.3.0):
[xxxxxxx@xxxxxxxxxxxxx.com] < Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing monolog/monolog (1.24.0):
[xxxxxxx@xxxxxxxxxxxxx.com] < Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing symfony/translation-contracts (v1.1.2):
[xxxxxxx@xxxxxxxxxxxxx.com] < Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing symfony/translation (v4.3.0):
[xxxxxxx@xxxxxxxxxxxxx.com] < Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing nesbot/carbon (2.19.1):
[xxxxxxx@xxxxxxxxxxxxx.com] < Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing psr/simple-cache (1.0.1): Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing psr/container (1.0.0):
[xxxxxxx@xxxxxxxxxxxxx.com] < Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing illuminate/contracts (v5.8.20): Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing doctrine/inflector (v1.3.0): Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing illuminate/support (v5.8.20): Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing illuminate/log (v5.8.20):
[xxxxxxx@xxxxxxxxxxxxx.com] < Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing illuminate/filesystem (v5.8.20):
[xxxxxxx@xxxxxxxxxxxxx.com] < Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing illuminate/container (v5.8.20):
[xxxxxxx@xxxxxxxxxxxxx.com] < Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing illuminate/events (v5.8.20): Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing illuminate/view (v5.8.20): Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing illuminate/translation (v5.8.20):
[xxxxxxx@xxxxxxxxxxxxx.com] < Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing doctrine/lexer (v1.0.1): Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing egulias/email-validator (2.1.8):
[xxxxxxx@xxxxxxxxxxxxx.com] < Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing illuminate/validation (v5.8.20):
[xxxxxxx@xxxxxxxxxxxxx.com] < Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing symfony/process (v4.3.0):
[xxxxxxx@xxxxxxxxxxxxx.com] < Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing opis/closure (3.3.0):
[xxxxxxx@xxxxxxxxxxxxx.com] < Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing illuminate/database (v5.8.20):
[xxxxxxx@xxxxxxxxxxxxx.com] < Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing illuminate/console (v5.8.20): Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing illuminate/queue (v5.8.20):
[xxxxxxx@xxxxxxxxxxxxx.com] < Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing illuminate/pipeline (v5.8.20): Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing illuminate/pagination (v5.8.20): Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing illuminate/session (v5.8.20): Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing illuminate/http (v5.8.20): Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing illuminate/hashing (v5.8.20): Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing illuminate/encryption (v5.8.20):
[xxxxxxx@xxxxxxxxxxxxx.com] < Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing illuminate/config (v5.8.20): Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing illuminate/cache (v5.8.20): Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing illuminate/bus (v5.8.20):
[xxxxxxx@xxxxxxxxxxxxx.com] < Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing illuminate/broadcasting (v5.8.20):
[xxxxxxx@xxxxxxxxxxxxx.com] < Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing illuminate/auth (v5.8.20): Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing laravel/lumen-framework (v5.8.8):
[xxxxxxx@xxxxxxxxxxxxx.com] < Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing paquettg/string-encode (1.0.1):
[xxxxxxx@xxxxxxxxxxxxx.com] < Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] <   - Installing paquettg/php-html-parser (2.0.2): Loading from cache
[xxxxxxx@xxxxxxxxxxxxx.com] <  Extracting archive
[xxxxxxx@xxxxxxxxxxxxx.com] < Writing lock file
[xxxxxxx@xxxxxxxxxxxxx.com] < Generating optimized autoload files
• done on [xxxxxxx@xxxxxxxxxxxxx.com]
✔ Ok [11s 27ms]
➤ Executing task deploy:writable
[xxxxxxx@xxxxxxxxxxxxx.com] > ps axo comm,user | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | sort | awk '{print $2}' | uniq
[xxxxxxx@xxxxxxxxxxxxx.com] < www-data
[xxxxxxx@xxxxxxxxxxxxx.com] > cd /var/www/service1/releases/1 && (mkdir -p bootstrap/cache storage storage/app storage/app/public storage/framework storage/framework/cache storage/framework/sessions storage/framework/views storage/logs)
[xxxxxxx@xxxxxxxxxxxxx.com] > cd /var/www/service1/releases/1 && (chmod 2>&1; true)
[xxxxxxx@xxxxxxxxxxxxx.com] < chmod: missing operand
[xxxxxxx@xxxxxxxxxxxxx.com] < Try 'chmod --help' for more information.
[xxxxxxx@xxxxxxxxxxxxx.com] > cd /var/www/service1/releases/1 && (if hash setfacl 2>/dev/null; then echo 'true'; fi)
[xxxxxxx@xxxxxxxxxxxxx.com] < true
[xxxxxxx@xxxxxxxxxxxxx.com] > cd /var/www/service1/releases/1 && (getfacl -p bootstrap/cache | grep "^user:www-data:.*w" | wc -l)
[xxxxxxx@xxxxxxxxxxxxx.com] > cd /var/www/service1/releases/1 && (setfacl -RL -m u:"www-data":rwX -m u:`whoami`:rwX bootstrap/cache)
[xxxxxxx@xxxxxxxxxxxxx.com] > cd /var/www/service1/releases/1 && (setfacl -dRL -m u:"www-data":rwX -m u:`whoami`:rwX bootstrap/cache)
[xxxxxxx@xxxxxxxxxxxxx.com] > cd /var/www/service1/releases/1 && (getfacl -p storage | grep "^user:www-data:.*w" | wc -l)
[xxxxxxx@xxxxxxxxxxxxx.com] < 1
[xxxxxxx@xxxxxxxxxxxxx.com] > cd /var/www/service1/releases/1 && (getfacl -p storage/app | grep "^user:www-data:.*w" | wc -l)
[xxxxxxx@xxxxxxxxxxxxx.com] < 1
[xxxxxxx@xxxxxxxxxxxxx.com] > cd /var/www/service1/releases/1 && (getfacl -p storage/app/public | grep "^user:www-data:.*w" | wc -l)
[xxxxxxx@xxxxxxxxxxxxx.com] < 1
[xxxxxxx@xxxxxxxxxxxxx.com] > cd /var/www/service1/releases/1 && (getfacl -p storage/framework | grep "^user:www-data:.*w" | wc -l)
[xxxxxxx@xxxxxxxxxxxxx.com] < 1
[xxxxxxx@xxxxxxxxxxxxx.com] > cd /var/www/service1/releases/1 && (getfacl -p storage/framework/cache | grep "^user:www-data:.*w" | wc -l)
[xxxxxxx@xxxxxxxxxxxxx.com] < 1
[xxxxxxx@xxxxxxxxxxxxx.com] > cd /var/www/service1/releases/1 && (getfacl -p storage/framework/sessions | grep "^user:www-data:.*w" | wc -l)
[xxxxxxx@xxxxxxxxxxxxx.com] < 1
[xxxxxxx@xxxxxxxxxxxxx.com] > cd /var/www/service1/releases/1 && (getfacl -p storage/framework/views | grep "^user:www-data:.*w" | wc -l)
[xxxxxxx@xxxxxxxxxxxxx.com] < 1
[xxxxxxx@xxxxxxxxxxxxx.com] > cd /var/www/service1/releases/1 && (getfacl -p storage/logs | grep "^user:www-data:.*w" | wc -l)
[xxxxxxx@xxxxxxxxxxxxx.com] < 1
• done on [xxxxxxx@xxxxxxxxxxxxx.com]
✔ Ok [1s 149ms]
➤ Executing task artisan:storage:link
[xxxxxxx@xxxxxxxxxxxxx.com] > cd /var/www/service1/releases/1 && /usr/bin/php artisan --version
[xxxxxxx@xxxxxxxxxxxxx.com] < Laravel Framework Lumen (5.8.8) (Laravel Components 5.8.*)
[xxxxxxx@xxxxxxxxxxxxx.com] > /usr/bin/php /var/www/service1/releases/1/artisan storage:link
[xxxxxxx@xxxxxxxxxxxxx.com] > Symfony\Component\Console\Exception\NamespaceNotFoundException: There are no commands defined in the "storage" namespace. in /var/www/service1/releases/1/vendor/symfony/console/Application.php:589 
[xxxxxxx@xxxxxxxxxxxxx.com] > Stack trace: 
[xxxxxxx@xxxxxxxxxxxxx.com] > #0 /var/www/service1/releases/1/vendor/symfony/console/Application.php(638): Symfony\Component\Console\Application->findNamespace('storage') 
[xxxxxxx@xxxxxxxxxxxxx.com] > #1 /var/www/service1/releases/1/vendor/symfony/console/Application.php(237): Symfony\Component\Console\Application->find('storage:link') 
[xxxxxxx@xxxxxxxxxxxxx.com] > #2 /var/www/service1/releases/1/vendor/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) 
[xxxxxxx@xxxxxxxxxxxxx.com] > #3 /var/www/service1/releases/1/vendor/illuminate/console/Application.php(90): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) 
[xxxxxxx@xxxxxxxxxxxxx.com] > #4 /var/www/service1/releases/1/vendor/laravel/lumen-framework/src/Console/Kernel.php(115): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) 
[xxxxxxx@xxxxxxxxxxxxx.com] > #5 /var/www/service1/releases/1/artisan(35): Laravel\Lumen\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #6 {main} {"exception":"[object] (Symfony\\Component\\Console\\Exception\\NamespaceNotFoundException(code: 0): There are no commands defined in the \"storage\" namespace. at /var/www/service1/releases/1/vendor/symfony/console/Application.php:589)"} []  
➤ Executing task deploy:failed
• done on [xxxxxxx@xxxxxxxxxxxxx.com]
✔ Ok [0ms]
➤ Executing task deploy:unlock
[xxxxxxx@xxxxxxxxxxxxx.com] > rm -f /var/www/service1/.dep/deploy.lock
• done on [xxxxxxx@xxxxxxxxxxxxx.com]
✔ Ok [70ms]

In Client.php line 99:

  [Deployer\Exception\RuntimeException (255)]                                                                                                               
  The command "/usr/bin/php /var/www/service1/releases/1/artisan storage:link" failed.                                                                      

  Exit Code: 255 (Unknown error)                                                                                                                            

  Host Name: xxxxxx@xxxxxxxxxxxxxxx.com                                                                                       

  ================                                                                                                                                          
  [2019-06-05 16:16:50] production.ERROR: Symfony\Component\Console\Exception\NamespaceNotFoundException: There are no commands defined in the "storage" namespace. in /var/www/service1/releases/1/vendor/symfony/console/Application.php:589 Stack trace: #0 /var/www/service1/releases/1/vendor/symfony/console/Application.php(638): Symfony\Component\Console\Application->findNamespace('storage') #1 /var/www/service1/releases/1/vendor/symfony/console/Application.php(237): Symfony\Component\Console\Application->find('storage:link') #2 /var/www/service1/releases/1/vendor/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #3 /var/www/service1/releases/1/vendor/illuminate/console/Application.php(90): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #4 /var/www/service1/releases/1/vendor/laravel/lumen-framework/src/Console/Kernel.php(115): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #5 /var/www/service1/releases/1/artisan(35): Laravel\Lumen\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #6 {main} {"exception":"[object] (Symfony\\Component\\Console\\Exception\\NamespaceNotFoundException(code: 0): There are no commands defined in the \"storage\" namespace. at /var/www/service1/releases/1/vendor/symfony/console/Application.php:589)"} []                                                 

Exception trace:
 Deployer\Ssh\Client->run() at phar:///usr/local/bin/dep/src/functions.php:304
 Deployer\run() at phar:///usr/local/bin/dep/recipe/laravel.php:137
 Deployer\Deployer::Deployer\{closure}() at n/a:n/a
 call_user_func() at phar:///usr/local/bin/dep/src/Task/Task.php:105
 Deployer\Task\Task->run() at phar:///usr/local/bin/dep/src/Executor/SeriesExecutor.php:60
 Deployer\Executor\SeriesExecutor->run() at phar:///usr/local/bin/dep/src/Console/TaskCommand.php:142
 Deployer\Console\TaskCommand->execute() at phar:///usr/local/bin/dep/vendor/symfony/console/Command/Command.php:252
 Symfony\Component\Console\Command\Command->run() at phar:///usr/local/bin/dep/vendor/symfony/console/Application.php:946
 Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/dep/src/Console/Application.php:133
 Deployer\Console\Application->doRunCommand() at phar:///usr/local/bin/dep/vendor/symfony/console/Application.php:248
 Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/dep/vendor/symfony/console/Application.php:148
 Symfony\Component\Console\Application->run() at phar:///usr/local/bin/dep/src/Deployer.php:331
 Deployer\Deployer::run() at phar:///usr/local/bin/dep/bin/dep:125
 require() at /usr/local/bin/dep:4
iamphilrae commented 5 years ago

From a previous Lumen issue I found here (https://github.com/deployphp/deployer/issues/1534), I think I have a potential "fix"(?). I've amended my deploy.php file to include the following, which I pulled out of the Laravel Recipe. Note the lines I have commented out which were failing for Lumen:

task('deploy', [
    'deploy:info',
    'deploy:prepare',
    'deploy:lock',
    'deploy:release',
    'deploy:update_code',
    'deploy:shared',
    'deploy:vendors',
    'deploy:writable',
    // 'artisan:storage:link',
    // 'artisan:view:clear',
    // 'artisan:config:cache',
    'artisan:optimize',
    'deploy:symlink',
    'deploy:unlock',
    'cleanup',
]);

Could someone well versed in this project please let me know if this is the appropriate thing to do? If so, it would be great for the sake of keeping the deploy.php file to a minimum, to have the Laravel Recipe updated to test for the lack of these artisan processes in Lumen, and therefore not attempt to run them.

Full deploy.php file for reference:

<?php
namespace Deployer;

require 'recipe/laravel.php';

// Project name
set('application', 'xxxxxxxxxxxxx');

// Project repository
set('repository', 'git@bitbucket.org:xxxxxxxxx/xxxxxxxxx.git');

// [Optional] Allocate tty for git clone. Default value is false.
set('git_tty', true);

// Shared files/dirs between deploys
add('shared_files', []);
add('shared_dirs', []);

// Writable dirs by web server
add('writable_dirs', []);

// Hosts

host('xxxxxxxxx@xxxxxxxxxx.com')
    ->stage('production')
    ->set('deploy_path', '/var/www/service1');

// Tasks

task('build', function () {
    run('cd {{release_path}} && build');
});

task('deploy', [
    'deploy:info',
    'deploy:prepare',
    'deploy:lock',
    'deploy:release',
    'deploy:update_code',
    'deploy:shared',
    'deploy:vendors',
    'deploy:writable',
    // 'artisan:storage:link',
    // 'artisan:view:clear',
    // 'artisan:config:cache',
    'artisan:optimize',
    'deploy:symlink',
    'deploy:unlock',
    'cleanup',
]);

// [Optional] if deploy fails automatically unlock.
after('deploy:failed', 'deploy:unlock');

// Migrate database before symlink new release.

before('deploy:symlink', 'artisan:migrate');
pluseg commented 5 years ago

@iamphilrae Hi Phil! As you can see here https://github.com/deployphp/deployer/tree/master/recipe, unfortunately, there is no recipe for Lumen. This means that you could a) take basic common.php and customize with your steps (which you can grab from laravel recipe, for example), b) take laravel recipe and customize it, but be aware that it could be changed in the future along with new major laravel release, c) create new recipe and push it as Pull Request. You can see, that any framework specific recipe is a common.php with additional steps. So, you could override steps, use them or not. It doesn't bring any overhead.

To summarize: I think that in your case, overriding Laravel main deploy task is okay.

iamphilrae commented 5 years ago

Thanks @pluseg. I was under the impression from this repo's past history that the Laraval recipe was intended to be compatible with Lumen as well (out the box). I've managed to get it to run, however my Laravel/Lumen knowledge is very limited so I wouldn't be confident in posting a PR. My answer above is 'working' though so the history is there for anyone looking in the future.

Thanks