deployer: Deployment Script suddenly failing with "a terminal is required to read the password"

  • Deployer version: v7.0.0-rc.4
  • Deployment OS: Ubuntu 21.10 deploying to 20.04

Just run the php-fpm:reload task.

image

err sudo: a terminal is required to read the password; either use the -S option to read from 
standard input or configure an askpass helper

deploy.php

<?php

namespace Deployer;

require 'recipe/laravel.php';
require 'contrib/php-fpm.php';
require 'contrib/npm.php';

/************************************************************************
 * Config
 ************************************************************************/
set('application', 'Funeral Stream');
//set('deploy_path', '~/{{application}}');
set('repository', 'git@bitbucket.org:webfoxDev/funeral.stream.app.git');
set('php_fpm_version', '8.0');

add('shared_files', []);
add('shared_dirs', []);
add('writable_dirs', []);

/************************************************************************
 * Hosts
 ************************************************************************/
host('production')
    ->setHostname('app.redacted.stream')
    ->setRemoteUser('forge')
    ->setDeployPath('/home/forge/app.redacted.stream')
    ->set('branch', 'master');

// host('staging')...

/************************************************************************
 * Tasks
 ************************************************************************/
desc('Deploy the project');
task('deploy', [
    'deploy:prepare',
    'deploy:vendors',
    'deploy:assets',
    'artisan:storage:link',
    'artisan:view:cache',
    'artisan:config:cache',
    'artisan:down',
    'artisan:migrate',
    'deploy:publish',
    'php-fpm:reload',
    'artisan:api:stripe-sync-prices',
    'artisan:up',
    'artisan:horizon:terminate',
]);

desc('Deploy local frontend assets');
task('deploy:assets', function () {
    runLocally('npm run prod');
    runLocally('npm run prod:embed');
    upload('./public/build/', '{{release_or_current_path}}/public/build', ['progress_bar' => false]);
    upload('./public/embed/', '{{release_or_current_path}}/public/embed', ['progress_bar' => false]);
});

desc('Terminate Horizon');
task('artisan:horizon:terminate', artisan('horizon:terminate'))
    ->select('production');

desc('Sync Stripe Prices');
task('artisan:api:stripe-sync-prices', artisan('api:stripe-sync-prices'));

desc('Reload FPM PHP');
task('php-fpm:reload', fn() => run('{{php_fpm_command}}'))
    ->select('production');

/************************************************************************
 * Hooks
 ************************************************************************/
after('deploy:failed', 'deploy:unlock');

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 15 (10 by maintainers)

Most upvoted comments

Fixed in 2fb0129a981edce4a0064efe4688a7e987fb3e74

@antonmedv, I found a solution to the problem.

Logs

7.0.0-rc.3 - php-fpm:reload is ok
done on production
done deploy:success 156ms
task php-fpm:reload
[production] /usr/bin/php8.1 /home/forge/.config/composer/vendor/deployer/deployer/bin/dep worker --port 38555 --task php-fpm:reload --host production --option branch=main -vvv
[production] warning Avoid reloading php-fpm [ï.at/avoid-php-fpm-reloading]
[production] ssh: is master running?
[production] ssh -O check -A -o ControlMaster=auto -o ControlPersist=60 -o ControlPath=/home/forge/.ssh/deployer_forge@api.dragon-code.pro echo
[production] Master running (pid=60415)
[production] ssh '-A' '-o' 'ControlMaster=auto' '-o' 'ControlPersist=60' '-o' 'ControlPath=/home/forge/.ssh/deployer_forge@api.dragon-code.pro' 'forge@api.dragon-code.pro' ': aa******************; bash -ls'
[production] run echo "" | sudo -S /usr/sbin/service php8.1-fpm reload
done on production
done php-fpm:reload 276ms
task artisan:queue:restart
[production] /usr/bin/php8.1 /home/forge/.config/composer/vendor/deployer/deployer/bin/dep worker --port 38555 --task artisan:queue:restart --host production --option branch=main -vvv
[production] ssh: is master running?
[production] ssh -O check -A -o ControlMaster=auto -o ControlPersist=60 -o ControlPath=/home/forge/.ssh/deployer_forge@api.dragon-code.pro echo
[production] Master running (pid=60415)
[production] ssh '-A' '-o' 'ControlMaster=auto' '-o' 'ControlPersist=60' '-o' 'ControlPath=/home/forge/.ssh/deployer_forge@api.dragon-code.pro' 'forge@api.dragon-code.pro' ': 9c******************;; bash -ls'
[production] run /usr/bin/php ~/api.dragon-code.pro/releases/89/artisan queue:restart
[production] Broadcasting queue restart signal.
done on production
done artisan:queue:restart 302ms
7.0.0-rc.4 - php-fpm:reload is failed
done on production
done deploy:success 91ms
task php-fpm:reload
[production] /usr/bin/php8.1 /home/forge/.config/composer/vendor/deployer/deployer/bin/dep worker --port 39787 --task php-fpm:reload --host production --option branch=main -vvv
[production] warning Avoid reloading php-fpm [ï.at/avoid-php-fpm-reloading]
[production] ssh: is master running?
[production] ssh -O check -A -o ControlMaster=auto -o ControlPersist=60 -o ControlPath=/home/forge/.ssh/deployer_forge@api.dragon-code.pro echo
[production] Master running (pid=60415)
[production] ssh '-A' '-o' 'ControlMaster=auto' '-o' 'ControlPersist=60' '-o' 'ControlPath=/home/forge/.ssh/deployer_forge@api.dragon-code.pro' 'forge@api.dragon-code.pro' ': d2******************;; bash -ls'
[production] run sudo systemctl reload php8.1-fpm
[production] sudo
[production] :
[production] a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
[production]  error  in php-fpm.php on line 49:
[production] exit code 1 (General error)
task deploy:failed
[production] /usr/bin/php8.1 /home/forge/.config/composer/vendor/deployer/deployer/bin/dep worker --port 39787 --task deploy:failed --host production --option branch=main -vvv
done on production
done deploy:failed 121ms
task deploy:unlock
[production] /usr/bin/php8.1 /home/forge/.config/composer/vendor/deployer/deployer/bin/dep worker --port 39787 --task deploy:unlock --host production --option branch=main -vvv
[production] ssh: is master running?
[production] ssh -O check -A -o ControlMaster=auto -o ControlPersist=60 -o ControlPath=/home/forge/.ssh/deployer_forge@api.dragon-code.pro echo
[production] Master running (pid=60415)
[production] ssh '-A' '-o' 'ControlMaster=auto' '-o' 'ControlPersist=60' '-o' 'ControlPath=/home/forge/.ssh/deployer_forge@api.dragon-code.pro' 'forge@api.dragon-code.pro' ': 68******************;; bash -ls'
[production] run rm -f ~/api.dragon-code.pro/.dep/deploy.lock
done on production
done deploy:unlock 121ms
deploy.php
<?php

namespace Deployer;

require 'recipe/laravel.php';
require 'contrib/php-fpm.php';
require 'contrib/npm.php';

// Config

set('application', 'TheDragonCode');
set('repository', 'git@github.com:my-repo-here.git');
set('php_fpm_version', '8.1');

// Hosts

host('production')
    ->setHostname('api.dragon-code.pro')
    ->setRemoteUser('forge')
    ->setDeployPath('~/{{hostname}}');

// Tasks

task('deploy', [
    'deploy:prepare',
    'deploy:vendors',
    'artisan:storage:link',
    'artisan:optimize:clear',
    'artisan:optimize',
    'artisan:view:cache',
    'artisan:event:cache',
    'artisan:migrate',
    'artisan:migrate:actions',
    'npm:install',
    'npm:run:prod',
    'deploy:publish',
    'php-fpm:reload',
    'artisan:queue:restart',
]);

task('artisan:migrate:actions', function () {
    cd('{{release_path}}');
    run('{{bin/php}} artisan migrate:actions --force');
});

task('npm:run:prod', function () {
    cd('{{release_path}}');
    run('npm run prod');
});

after('deploy:failed', 'deploy:unlock');

7.0.0-rc.3

set('php_fpm_command', 'echo "" | sudo -S /usr/sbin/service {{php_fpm_service}} reload');

7.0.0-rc.4

set('php_fpm_command', 'sudo systemctl reload {{php_fpm_service}}');

And if I run these commands manually:

forge@gorgeous-atoll:~$ sudo systemctl reload php8.1-fpm
[sudo] password for forge:

forge@gorgeous-atoll:~$ echo "" | sudo -S /usr/sbin/service php8.1-fpm reload
forge@gorgeous-atoll:~$

Bads: