deployphp / deployer

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

systemctl: command not found #1151

Closed paishin closed 7 years ago

paishin commented 7 years ago
Q When trying to deploy to CentOs server that does not have systemctl I get the following error, is there a way to bypass this problem? A
Issue Type Question
Deployer Version 4.3.0
Local Machine OS Ubuntu
Remote Machine OS CentOS6

Description

If you're reporting a bug, please include following information

Steps to reproduce

Content of deploy.php

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

// Configuration

set('ssh_type', 'native');
set('ssh_multiplexing', true);

set('repository', 'git@bitbucket.org:paikki/overwatch.git');

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

add('writable_dirs', []);

// Servers

server('production', 'milkshake.cc')
    ->user('xxxxxxxxxx')
    ->password('xxxxxxxxxxxxx')
    ->port(222)
    ->set('deploy_path', '/home/mlkshake/public_html')
    ->stage('production');

// Tasks

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.

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

Output log

With enabled option for verbose output -vvv.

vagrant@overwatch-backend:~/Code/overwatch-backend$ dep deploy production -vvv ➤ Executing task deploy:prepare [production] > echo $0 SSH multiplexing initialization mlkshake@milkshake.cc's password: Permission denied, please try again. mlkshake@milkshake.cc's password: stdin: is not a tty [production] < bash [production] > if [ ! -d /home/mlkshake/public_html ]; then mkdir -p /home/mlkshake/public_html; fi [production] > if [ ! -L /home/mlkshake/public_html/current ] && [ -d /home/mlkshake/public_html/current ]; then echo true; fi [production] > cd /home/mlkshake/public_html && if [ ! -d .dep ]; then mkdir .dep; fi [production] > cd /home/mlkshake/public_html && if [ ! -d releases ]; then mkdir releases; fi [production] > cd /home/mlkshake/public_html && if [ ! -d shared ]; then mkdir shared; fi • done on [production] ✔ Ok [23s 137ms] ➤ Executing task deploy:lock [production] > if [ -f /home/mlkshake/public_html/.dep/deploy.lock ]; then echo 'true'; fi [production] > touch /home/mlkshake/public_html/.dep/deploy.lock • done on [production] ✔ Ok [823ms] ➤ Executing task deploy:release [production] > cd /home/mlkshake/public_html && (if [ -h release ]; then echo 'true'; fi) [production] > cd /home/mlkshake/public_html && ([ -d releases ] && [ "$(ls -A releases)" ] && echo "true" || echo "false") [production] < true [production] > cd /home/mlkshake/public_html && (cd releases && ls -t -1 -d */) [production] < 8/ [production] < 7/ [production] < 6/ [production] < 5/ [production] < 4/ [production] < 3/ [production] < 2/ [production] < 1/ [production] > cd /home/mlkshake/public_html && (if [ -f .dep/releases ]; then echo "true"; fi) [production] < true [production] > cd /home/mlkshake/public_html && (tail -n 15 .dep/releases) [production] < 20170407012029,1 [production] < 20170407012213,1 [production] < 20170407014452,1 [production] < 20170407015114,1 [production] < 20170407015403,1 [production] < 20170407015559,1 [production] < 20170407020343,2 [production] < 20170407020841,3 [production] < 20170407022035,4 [production] < 20170407024304,5 [production] < 20170407024430,6 [production] < 20170407025031,7 [production] < 20170407031238,8 [production] < stdin: is not a tty [production] < 20170407031631,1 [production] > cd /home/mlkshake/public_html && (if [ -d /home/mlkshake/public_html/releases/9 ]; then echo 'true'; fi) [production] > cd /home/mlkshake/public_html && (date +"%Y%m%d%H%M%S") [production] < 20170407031751 [production] > cd /home/mlkshake/public_html && (echo '20170407031751,9' >> .dep/releases) [production] > cd /home/mlkshake/public_html && (mkdir /home/mlkshake/public_html/releases/9) [production] > cd /home/mlkshake/public_html && (if [[ "$(man ln)" =~ "--relative" ]]; then echo "true"; fi) [production] > cd /home/mlkshake/public_html && (ln -nfs /home/mlkshake/public_html/releases/9 /home/mlkshake/public_html/release) • done on [production] ✔ Ok [4s 220ms] ➤ Executing task deploy:update_code [production] > which git [production] < /usr/local/bin/git [production] > /usr/local/bin/git version [production] < git version 2.11.1 [production] > if [ -h /home/mlkshake/public_html/release ]; then echo 'true'; fi [production] < true [production] > readlink /home/mlkshake/public_html/release [production] < /home/mlkshake/public_html/releases/9 [production] > /usr/local/bin/git clone --recursive -q --reference /home/mlkshake/public_html/releases/8 --dissociate git@bitbucket.org:paikki/overwatch.git /home/mlkshake/public_html/releases/9 2>&1 • done on [production] ✔ Ok [3s 536ms] ➤ Executing task deploy:shared [production] > if [ -d /home/mlkshake/public_html/shared/storage ]; then echo 'true'; fi [production] < true [production] > rm -rf /home/mlkshake/public_html/releases/9/storage [production] > mkdir -pdirname /home/mlkshake/public_html/releases/9/storage [production] > ln -nfs /home/mlkshake/public_html/shared/storage /home/mlkshake/public_html/releases/9/storage [production] > if [ -f $(echo /home/mlkshake/public_html/releases/9/.env) ]; then rm -rf /home/mlkshake/public_html/releases/9/.env; fi [production] > if [ ! -d $(echo /home/mlkshake/public_html/releases/9/.) ]; then mkdir -p /home/mlkshake/public_html/releases/9/.;fi [production] > mkdir -p /home/mlkshake/public_html/shared/. [production] > touch /home/mlkshake/public_html/shared/.env [production] > ln -nfs /home/mlkshake/public_html/shared/.env /home/mlkshake/public_html/releases/9/.env • done on [production] ✔ Ok [3s 446ms] ➤ Executing task deploy:vendors [production] > if hash composer 2>/dev/null; then echo 'true'; fi [production] > which php [production] < /usr/local/bin/php [production] > cd /home/mlkshake/public_html/releases/9 && curl -sS https://getcomposer.org/installer | /usr/local/bin/php [production] < All settings correct for using Composer [production] < Downloading... [production] < [production] < Composer (version 1.4.1) successfully installed to: /home/mlkshake/public_html/releases/9/composer.phar [production] < Use it: php composer.phar [production] > cd /home/mlkshake/public_html/releases/9 && /usr/local/bin/php /home/mlkshake/public_html/releases/9/composer.phar install --verbose --prefer-dist --no-progress --no-interaction --no-dev --optimize-autoloader • done on [production] ✔ Ok [6s 88ms] ➤ Executing task deploy:writable [production] > ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1 [production] < nobody [production] > cd /home/mlkshake/public_html/releases/9 && (mkdir -p bootstrap/cache storage storage/app storage/app/public storage/framework storage/framework/cache storage/framework/sessions storage/framework/views storage/logs) [production] > cd /home/mlkshake/public_html/releases/9 && (chmod 2>&1; true) [production] < chmod: missing operand [production] < Trychmod --help' for more information. [production] > cd /home/mlkshake/public_html/releases/9 && (if hash setfacl 2>/dev/null; then echo 'true'; fi) [production] < true [production] > cd /home/mlkshake/public_html/releases/9 && (getfacl -p bootstrap/cache | grep "^user:nobody:.w" | wc -l) [production] < 0 [production] > cd /home/mlkshake/public_html/releases/9 && (setfacl -RL -m u:"nobody":rwX -m u:whoami:rwX bootstrap/cache) [production] > cd /home/mlkshake/public_html/releases/9 && (setfacl -dRL -m u:"nobody":rwX -m u:whoami:rwX bootstrap/cache) [production] > cd /home/mlkshake/public_html/releases/9 && (getfacl -p storage | grep "^user:nobody:.w" | wc -l) [production] < 4 [production] > cd /home/mlkshake/public_html/releases/9 && (getfacl -p storage/app | grep "^user:nobody:.w" | wc -l) [production] < 1 [production] > cd /home/mlkshake/public_html/releases/9 && (getfacl -p storage/app/public | grep "^user:nobody:.w" | wc -l) [production] < 1 [production] > cd /home/mlkshake/public_html/releases/9 && (getfacl -p storage/framework | grep "^user:nobody:.w" | wc -l) [production] < 1 [production] > cd /home/mlkshake/public_html/releases/9 && (getfacl -p storage/framework/cache | grep "^user:nobody:.w" | wc -l) [production] < 1 [production] > cd /home/mlkshake/public_html/releases/9 && (getfacl -p storage/framework/sessions | grep "^user:nobody:.w" | wc -l) [production] < 1 [production] > cd /home/mlkshake/public_html/releases/9 && (getfacl -p storage/framework/views | grep "^user:nobody:.w" | wc -l) [production] < 1 [production] > cd /home/mlkshake/public_html/releases/9 && (getfacl -p storage/logs | grep "^user:nobody:.*w" | wc -l) [production] < 1 • done on [production] ✔ Ok [5s 871ms] ➤ Executing task artisan:view:clear [production] > /usr/local/bin/php /home/mlkshake/public_html/releases/9/artisan view:clear [production] < Compiled views cleared! • done on [production] ✔ Ok [946ms] ➤ Executing task artisan:cache:clear [production] > /usr/local/bin/php /home/mlkshake/public_html/releases/9/artisan cache:clear [production] < Cache cleared successfully. • done on [production] ✔ Ok [516ms] ➤ Executing task artisan:config:cache [production] > /usr/local/bin/php /home/mlkshake/public_html/releases/9/artisan config:cache [production] < Configuration cache cleared! [production] < Configuration cached successfully! • done on [production] ✔ Ok [551ms] ➤ Executing task artisan:optimize [production] > /usr/local/bin/php /home/mlkshake/public_html/releases/9/artisan optimize [production] < Generating optimized class loader [production] < The compiled services file has been removed. • done on [production] ✔ Ok [2s 2ms] ➤ Executing task artisan:migrate [production] > /usr/local/bin/php /home/mlkshake/public_html/releases/9/artisan migrate --force [production] < Nothing to migrate. • done on [production] ✔ Ok [556ms] ➤ Executing task deploy:symlink [production] > if [[ "$(man mv)" =~ "--no-target-directory" ]]; then echo "true"; fi [production] > cd /home/mlkshake/public_html && ln -nfs /home/mlkshake/public_html/releases/9 current [production] > cd /home/mlkshake/public_html && rm release • done on [production] ✔ Ok [1s 184ms] ➤ Executing task php-fpm:restart [production] > sudo systemctl restart php-fpm.service ➤ Executing task deploy:failed • done on [production] ✔ Ok [0ms] ➤ Executing task deploy:unlock [production] > rm -f /home/mlkshake/public_html/.dep/deploy.lock • done on [production] ✔ Ok [370ms]

[RuntimeException]
The command "ssh -A -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ControlMaster=auto -o ControlPersist=5 -o Contr
olPath='~/.ssh/deployer_mux_mlkshake@milkshake.cc:222' -p '222' 'mlkshake@milkshake.cc' bash -s" failed.
Exit Code: 1(General error)
Working directory: /home/vagrant/Code/overwatch-backend
Output:
================
Error Output:
================
stdin: is not a tty
sudo: systemctl: command not found

Exception trace: () at phar:///usr/local/bin/dep/src/Server/Remote/NativeSsh.php:103 Deployer\Server\Remote\NativeSsh->run() at phar:///usr/local/bin/dep/src/functions.php:318 Deployer\run() at /home/vagrant/Code/overwatch-backend/deploy.php:33 Deployer{closure}() at n/a:n/a call_user_func() at phar:///usr/local/bin/dep/src/Task/Task.php:85 Deployer\Task\Task->run() at phar:///usr/local/bin/dep/src/Executor/SeriesExecutor.php:40 Deployer\Executor\SeriesExecutor->run() at phar:///usr/local/bin/dep/src/Console/TaskCommand.php:103 Deployer\Console\TaskCommand->execute() at phar:///usr/local/bin/dep/vendor/symfony/console/Command/Command.php:262 Symfony\Component\Console\Command\Command->run() at phar:///usr/local/bin/dep/vendor/symfony/console/Application.php:826 Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/dep/src/Console/Application.php:123 Deployer\Console\Application->doRunCommand() at phar:///usr/local/bin/dep/vendor/symfony/console/Application.php:189 Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/dep/vendor/symfony/console/Application.php:120 Symfony\Component\Console\Application->run() at phar:///usr/local/bin/dep/src/Deployer.php:190 Deployer\Deployer->run() at phar:///usr/local/bin/dep/bin/dep:119 require() at /usr/local/bin/dep:4

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

antonmedv commented 7 years ago

remove it:

after('deploy:symlink', 'php-fpm:restart');