Deployer: Deployer failed complete deploying

Created on 20 Jun 2017  ·  7Comments  ·  Source: deployphp/deployer

| Q | A
| ----------------- | ---
| Issue Type | Question
| Deployer Version | 5
| Local Machine OS | Windows-10
| Remote Machine OS | Debian_8.7(Jessie)

Description

When trying to deploy, deployer creates the directories properly on remote machine but fails and throws errors as below:

Steps to reproduce

Content of deploy.php

 <?php
namespace Deployer;
require 'recipe/laravel.php';

// Configuration
set('keep_releases', 5);
set('ssh_type', 'native');
set('ssh_multiplexing', true);
set('branch', 'master');
set('repository', 'git@ip:root/~/temp/repo.git');

add('shared_files', [
    '.env'
]);
add('shared_dirs', [
    'storage'
]);

add('writable_dirs', [
    'bootstrap/cache',
    'storage',
    'storage/app',
    'storage/app/public',
    'storage/framework',
    'storage/framework/cache',
    'storage/framework/sessions',
    'storage/framework/views',
    'storage/logs',
]);

// Servers

server('production', 'ip')
    ->user('root')
    ->identityFile()
    ->configFile('~/.ssh/config')
    ->set('deploy_path', '/var/www/domain')
    ->pty(true);


// Tasks

task('upload:env', function () {
    upload('.env.production', '{{deploy_path}}/shared/.env');
})->desc('Environment setup');


desc('Restart PHP-FPM service');
task('php-fpm:restart', function () {
    // The user must have rights for restart service
    // /etc/sudoers: username ALL=NOPASSWD:/bin/systemctl restart php-fpm.service
    run('sudo systemctl restart php-fpm.service');
});
after('deploy:symlink', 'php-fpm:restart');

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

// Migrate database before symlink new release.
desc('Deploy your project');
task('deploy', [
    'deploy:prepare',
    'deploy:lock',
    'deploy:release',
    'deploy:update_code',
    'deploy:shared',
    'upload:env',
    'deploy:vendors',
    'deploy:writable',
    'artisan:migrate',
    'artisan:view:clear',
    'artisan:cache:clear',
    'artisan:config:cache',
    'artisan:route:cache',
    'artisan:optimize',
    'deploy:symlink',
    'deploy:unlock',
    'cleanup',
]);



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

Output log

$ dep deploy -vvv                                                                                                                                                                                                                               
➤ Executing task deploy:prepare                                                                                                                                                                                                                 
[production] > echo $0                                                                                                                                                                                                                          
  SSH multiplexing initialization                                                                                                                                                                                                               
mux_client_request_session: read from master failed: Connection reset by peer                                                                                                                                                                   
Failed to connect to new control master                                                                                                                                                                                                         
[production] < bash                                                                                                                                                                                                                             
[production] > if [ ! -d /var/www/domain ]; then mkdir -p /var/www/domain; fi                                                                                                                                                             
➤ Executing task deploy:failed                                                                                                                                                                                                                  
• done on [production]                                                                                                                                                                                                                          
✔️ Ok [1ms]                                                                                                                                                                                                                                      
➤ Executing task deploy:unlock                                                                                                                                                                                                                  
[production] > rm -f /var/www/domain/.dep/deploy.lock                                                                                                                                                                                        


  [RuntimeException]                                                                                                                                                                                                                            
  The command "ssh -A -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ControlMaster=auto -o ControlPersist=5 -o ControlPath='~/.ssh/deployer_mux_root@remote_machine_ip:22' -F "C:\Users\EMKING/.ssh/config" -p "22" -i "C:\Users\

E   
  MKING/.ssh/id_rsa" -t "root@remote_machine_ip" bash -s" failed.                                                                                                                                                                                    
  Exit Code: 255(Unknown error)                                                                                                                                                                                                                 
  Working directory: E:\User\meeveh                                                                                                                                                                                                          
  Output:                                                                                                                                                                                                                                       
  ================                                                                                                                                                                                                                              
  Error Output:                                                                                                                                                                                                                                 
  ================                                                                                                                                                                                                                              
  Pseudo-terminal will not be allocated because stdin is not a terminal.                                                                                                                                                                        
  mm_send_fd: sendmsg(2): Connection reset by peer                                                                                                                                                                                              
  mux_client_request_session: send fds failed                                                                                                                                                                                                   


Exception trace:                                                                                                                                                                                                                                
 () at C:\Users\EMKING\AppData\Roaming\Composer\vendor\deployer\deployer\src\Server\Remote\NativeSsh.php:103                                                                                                                                    
 Deployer\Server\Remote\NativeSsh->run() at C:\Users\EMKING\AppData\Roaming\Composer\vendor\deployer\deployer\src\functions.php:318                                                                                                             
 Deployer\run() at C:\Users\EMKING\AppData\Roaming\Composer\vendor\deployer\deployer\recipe\deploy\lock.php:28                                                                                                                                  
 Deployer\{closure}() at n/a:n/a

call_user_func() at C:\Users\EMKING\AppData\Roaming\Composer\vendor\deployer\deployer\src\Task\Task.php:85                                                                                                                                     
 Deployer\Task\Task->run() at C:\Users\EMKING\AppData\Roaming\Composer\vendor\deployer\deployer\src\Executor\SeriesExecutor.php:40                                                                                                              
 Deployer\Executor\SeriesExecutor->run() at C:\Users\EMKING\AppData\Roaming\Composer\vendor\deployer\deployer\src\Console\TaskCommand.php:112                                                                                                   
 Deployer\Console\TaskCommand->execute() at C:\Users\EMKING\AppData\Roaming\Composer\vendor\symfony\console\Command\Command.php:262                                                                                                             
 Symfony\Component\Console\Command\Command->run() at C:\Users\EMKING\AppData\Roaming\Composer\vendor\symfony\console\Application.php:826                                                                                                        
 Symfony\Component\Console\Application->doRunCommand() at C:\Users\EMKING\AppData\Roaming\Composer\vendor\deployer\deployer\src\Console\Application.php:123                                                                                     
 Deployer\Console\Application->doRunCommand() at C:\Users\EMKING\AppData\Roaming\Composer\vendor\symfony\console\Application.php:190                                                                                                            
 Symfony\Component\Console\Application->doRun() at C:\Users\EMKING\AppData\Roaming\Composer\vendor\symfony\console\Application.php:121                                                                                                          
 Symfony\Component\Console\Application->run() at C:\Users\EMKING\AppData\Roaming\Composer\vendor\deployer\deployer\src\Deployer.php:190                                                                                                         
 Deployer\Deployer->run() at C:\Users\EMKING\AppData\Roaming\Composer\vendor\deployer\deployer\bin\dep:120                                                                                                                                      

deploy [-p|--parallel] [--no-hooks]                                                                                                                             

Most helpful comment

In addition to @antonmedv's suggestion to use bash on windows (i.e. Windows Subsystem for Linux), which works, you can also make the Cygwin-caused mux_client_request_session problem go away by turning off ssh multiplexing.

i.e. in your deploy.php, change:
set('ssh_multiplexing', true);
to
set('ssh_multiplexing', false);

or if your version of deployer CLI supports it (I'm not seeing the -o option but since WSL is working I can't be bothered to dig) you can override config options from the command line, e.g.
dep deploy -o ssh_multiplexing=false ...

All 7 comments

It's a bug in cygwin https://cygwin.com/ml/cygwin/2010-08/msg00072.html
Try bash on windows

@antonmedv Now i'm using open-ssh and it throws new error below:

> dep deploy -vvv
➤ Executing task deploy:prepare
[production] > echo $0
[production] < bash
[production] > if [ ! -d /var/www/domain ]; then mkdir -p /var/www/domain; fi
[production] > if [ ! -L /var/www/domain/current ] && [ -d /var/www/domain/current ]; then echo true; fi
[production] > cd /var/www/domain && if [ ! -d .dep ]; then mkdir .dep; fi
[production] > cd /var/www/domain && if [ ! -d releases ]; then mkdir releases; fi
[production] > cd /var/www/domain && if [ ! -d shared ]; then mkdir shared; fi
• done on [production]
✔️ Ok [4s 912ms]
➤ Executing task deploy:lock
[production] > if [ -f /var/www/domain/.dep/deploy.lock ]; then echo 'true'; fi
[production] > touch /var/www/domain/.dep/deploy.lock
• done on [production]
✔️ Ok [1s 633ms]
➤ Executing task deploy:release
[production] > cd /var/www/domain && (if [ -h release ]; then echo 'true'; fi)
[production] > cd /var/www/domain && ([ -d releases ] && [ "$(ls -A releases)" ] && echo "true" || echo "false")
[production] < true
[production] > cd /var/www/domain && (cd releases && ls -t -1 -d */)
[production] < 1/
[production] > cd /var/www/domain && (if [ -f .dep/releases ]; then echo "true"; fi)
[production] < true
[production] > cd /var/www/domain && (tail -n 15 .dep/releases)
[production] < 20170620062803,1
[production] < 20170620063338,1
[production] < 20170620064326,1
[production] < 20170620070357,1
[production] < 20170620094712,1
[production] > cd /var/www/domain && (if [ -d /var/www/domain/releases/2 ]; then echo 'true'; fi)
[production] > cd /var/www/domain && (date +"%Y%m%d%H%M%S")
[production] < 20170620095156
[production] > cd /var/www/domain && (echo '20170620095156,2' >> .dep/releases)
[production] > cd /var/www/domain && (mkdir /var/www/domain/releases/2)
[production] > cd /var/www/domain && (if [[ "$(man ln)" =~ "--relative" ]]; then echo "true"; fi)
[production] < true
[production] > cd /var/www/domain && (ln -nfs --relative /var/www/domain/releases/2 /var/www/domain/release)
➤ Executing task deploy:failed
• done on [production]
✔️ Ok [1ms]
➤ Executing task deploy:unlock
[production] > rm -f /var/www/domain/.dep/deploy.lock
• done on [production]
✔️ Ok [821ms]


  [RuntimeException]
  The command "ssh -A -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -F "C:\Users\EMKING/.ssh/config" -p "22" -i "C:\Users\EMKING/.ssh/id_rsa" "root@remote_machine_ip" bash -s" failed.
  Exit Code: 255(Unknown error)
  Working directory: E:\User\meeveh
  Output:
  ================
  Error Output:
  ================
  Connection reset by remote_machine_ip port 22


Exception trace:
 () at C:\Users\EMKING\AppData\Roaming\Composer\vendor\deployer\deployer\src\Server\Remote\NativeSsh.php:103
 Deployer\Server\Remote\NativeSsh->run() at C:\Users\EMKING\AppData\Roaming\Composer\vendor\deployer\deployer\src\functions.php:318
 Deployer\run() at C:\Users\EMKING\AppData\Roaming\Composer\vendor\deployer\deployer\recipe\deploy\release.php:128
 Deployer\{closure}() at n/a:n/a
 call_user_func() at C:\Users\EMKING\AppData\Roaming\Composer\vendor\deployer\deployer\src\Task\Task.php:85
 Deployer\Task\Task->run() at C:\Users\EMKING\AppData\Roaming\Composer\vendor\deployer\deployer\src\Executor\SeriesExecutor.php:40
 Deployer\Executor\SeriesExecutor->run() at C:\Users\EMKING\AppData\Roaming\Composer\vendor\deployer\deployer\src\Console\TaskCommand.php:103
 Deployer\Console\TaskCommand->execute() at C:\Users\EMKING\AppData\Roaming\Composer\vendor\symfony\console\Command\Command.php:262
 Symfony\Component\Console\Command\Command->run() at C:\Users\EMKING\AppData\Roaming\Composer\vendor\symfony\console\Application.php:826
 Symfony\Component\Console\Application->doRunCommand() at C:\Users\EMKING\AppData\Roaming\Composer\vendor\deployer\deployer\src\Console\Application.php:123
 Deployer\Console\Application->doRunCommand() at C:\Users\EMKING\AppData\Roaming\Composer\vendor\symfony\console\Application.php:190
 Symfony\Component\Console\Application->doRun() at C:\Users\EMKING\AppData\Roaming\Composer\vendor\symfony\co

nsole\Application.php:121
 Symfony\Component\Console\Application->run() at C:\Users\EMKING\AppData\Roaming\Composer\vendor\deployer\deployer\src\Deployer.php:190
 Deployer\Deployer->run() at C:\Users\EMKING\AppData\Roaming\Composer\vendor\deployer\deployer\bin\dep:120

deploy [-p|--parallel] [--no-hooks]



try this:

set('use_relative_symlinks', false);

@akoSalman fixed?)

I'm closing this issue as no activity for more then 2 weeks. I hope you found a solution (please, share with us).

If you still have any problems feel free to open a new issue.

In addition to @antonmedv's suggestion to use bash on windows (i.e. Windows Subsystem for Linux), which works, you can also make the Cygwin-caused mux_client_request_session problem go away by turning off ssh multiplexing.

i.e. in your deploy.php, change:
set('ssh_multiplexing', true);
to
set('ssh_multiplexing', false);

or if your version of deployer CLI supports it (I'm not seeing the -o option but since WSL is working I can't be bothered to dig) you can override config options from the command line, e.g.
dep deploy -o ssh_multiplexing=false ...

@antonmedv Thanks for saving my time. It worked.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JonasDoebertin picture JonasDoebertin  ·  4Comments

dima-stefantsov picture dima-stefantsov  ·  4Comments

timkley picture timkley  ·  4Comments

sweebee picture sweebee  ·  3Comments

minkbear picture minkbear  ·  4Comments