Я использую следующую конфигурацию для своего промежуточного сервера, я настроил это до 2 недель, которые работали без проблем. Сегодня я выполнил бум, и он рухнул без подробного объяснения точки сбоя. Я понятия не имею, что здесь происходит.
Capfile
# Load DSL and set up stages
require 'capistrano/setup'
# Include default deployment tasks
require 'capistrano/deploy'
# Include composer plugin
require 'capistrano/composer'
# Include symfony plugin
require 'capistrano/symfony'
# Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
deploy.rb
# config valid only for current version of Capistrano
lock '3.4.0'
set :application, 'application1'
set :repo_url, '[email protected]:repo/application1.git'
# Symfony bin path
set :bin_path, "bin"
# Symfony var path
set :var_path, "var"
# Symfony console path
set :symfony_console_path, fetch(:bin_path) + "/console"
# Symfony log path
set :log_path, fetch(:var_path) + "/logs"
# Symfony cache path
set :cache_path, fetch(:var_path) + "/cache"
# Method used to set permissions (:chmod, :acl, or :chown)
#set :permission_method, "chmod"
# Execute set permissions
#set :use_set_permissions, true
# Default branch is :master
# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp
# Default value for :scm is :git
# set :scm, :git
# Default value for :format is :pretty
# set :format, :pretty
# Default value for :log_level is :debug
# set :log_level, :debug
# Default value for :pty is false
# set :pty, true
# Default value for :linked_files is []
# set :linked_files, fetch(:linked_files, []).push('config/database.yml', 'config/secrets.yml')
# Default value for linked_dirs is []
# set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system')
# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
# Default value for keep_releases is 5
# set :keep_releases, 5
set :log_level, :debug
set :ssh_options, {
verbose: :debug
}
namespace :deploy do
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
# Here we can do anything such as:
# within release_path do
# execute :rake, 'cache:clear'
# end
end
end
before :starting, :map_composer_command do
on roles(:web) do |server|
SSHKit.config.command_map[:composer] = "php #{shared_path.join("composer.phar")}"end
end
after :starting, 'composer:install_executable'
after 'deploy:updated', 'symfony:assets:install'
after 'deploy:updated', 'symfony:assetic:dump'
task :updating do
invoke "symfony:set_permissions"end
end
/deploy/staging.rb
set :deploy_to, '/home/application/www/'
set :branch, 'develop'
role :web, %w{[email protected]}
set :ssh_options, {
forward_agent: false,
auth_methods: %w(publickey)
}
deployment.log
➜ ~ git:(develop) ✗ cap staging deploy --trace
** Invoke staging (first_time)
** Execute staging
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke deploy:set_symfony_env (first_time)
** Execute deploy:set_symfony_env
** Invoke deploy (first_time)
** Execute deploy
** Invoke deploy:starting (first_time)
** Invoke deploy:map_composer_command (first_time)
** Execute deploy:map_composer_command
** Execute deploy:starting
** Invoke deploy:check (first_time)
** Execute deploy:check
** Invoke git:check (first_time)
** Invoke git:wrapper (first_time)
** Execute git:wrapper
INFO [71e8902f] Running /usr/bin/env mkdir -p /tmp/application1/ as [email protected]
DEBUG [71e8902f] Command: ( SYMFONY_ENV=prod /usr/bin/env mkdir -p /tmp/application1/ )
INFO [71e8902f] Finished in 1.388 seconds with exit status 0 (successful).
DEBUG Uploading /tmp/application1/git-ssh.sh 0.0%
INFO Uploading /tmp/application1/git-ssh.sh 100.0%
INFO [b72203c5] Running /usr/bin/env chmod +x /tmp/application1/git-ssh.sh as [email protected]
DEBUG [b72203c5] Command: ( SYMFONY_ENV=prod /usr/bin/env chmod +x /tmp/application1/git-ssh.sh )
INFO [b72203c5] Finished in 0.114 seconds with exit status 0 (successful).
** Execute git:check
INFO [6b71bde0] Running /usr/bin/env git ls-remote --heads [email protected]:repo/application1.git as [email protected]
DEBUG [6b71bde0] Command: ( SYMFONY_ENV=prod GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/application1/git-ssh.sh /usr/bin/env git ls-remote --heads [email protected]:repo/application1.git )
DEBUG [6b71bde0] 689b63faef191d5ffdeae9542199c10f52595be2 refs/heads/develop
DEBUG [6b71bde0] d897de07d00263d9c6bc8c61b86063735bf5a0a3 refs/heads/frontend
DEBUG [6b71bde0] 9f1ba44668704fbf3804bee8c6b8454b2d89d0b3 refs/heads/master
INFO [6b71bde0] Finished in 1.701 seconds with exit status 0 (successful).
** Invoke deploy:check:directories (first_time)
** Execute deploy:check:directories
INFO [772cd442] Running /usr/bin/env mkdir -p /home/application/www/shared /home/application/www/releases as [email protected]
DEBUG [772cd442] Command: ( SYMFONY_ENV=prod /usr/bin/env mkdir -p /home/application/www/shared /home/application/www/releases )
INFO [772cd442] Finished in 0.116 seconds with exit status 0 (successful).
** Invoke deploy:check:linked_dirs (first_time)
** Execute deploy:check:linked_dirs
INFO [d9b60714] Running /usr/bin/env mkdir -p /home/application/www/shared/app/logs /home/application/www/shared/web/uploads as [email protected]
DEBUG [d9b60714] Command: ( SYMFONY_ENV=prod /usr/bin/env mkdir -p /home/application/www/shared/app/logs /home/application/www/shared/web/uploads )
INFO [d9b60714] Finished in 0.119 seconds with exit status 0 (successful).
** Invoke deploy:check:make_linked_dirs (first_time)
** Execute deploy:check:make_linked_dirs
** Invoke deploy:check:linked_files (first_time)
** Execute deploy:check:linked_files
** Invoke deploy:set_previous_revision (first_time)
** Execute deploy:set_previous_revision
DEBUG [553720ba] Running /usr/bin/env [ -f /home/application/www/current/REVISION ] as [email protected]
DEBUG [553720ba] Command: [ -f /home/application/www/current/REVISION ]
DEBUG [553720ba] Finished in 0.112 seconds with exit status 1 (failed).
** Invoke composer:install_executable (first_time)
** Execute composer:install_executable
DEBUG [361e6263] Running /usr/bin/env if test ! -d /home/application/www/shared; then echo "Directory does not exist '/home/application/www/shared'" 1>&2; false; fi as [email protected]
DEBUG [361e6263] Command: if test ! -d /home/application/www/shared; then echo "Directory does not exist '/home/application/www/shared'" 1>&2; false; fi
DEBUG [361e6263] Finished in 0.115 seconds with exit status 0 (successful).
DEBUG [46f49c74] Running /usr/bin/env [ -e composer.phar ] as [email protected]
DEBUG [46f49c74] Command: cd /home/application/www/shared && ( SYMFONY_ENV=prod /usr/bin/env [ -e composer.phar ] )
DEBUG [46f49c74] Finished in 0.126 seconds with exit status 0 (successful).
** Invoke deploy:started (first_time)
** Execute deploy:started
** Invoke deploy:updating (first_time)
** Invoke deploy:new_release_path (first_time)
** Execute deploy:new_release_path
** Execute deploy:updating
** Invoke git:create_release (first_time)
** Invoke git:update (first_time)
** Invoke git:clone (first_time)
** Invoke git:wrapper
** Execute git:clone
DEBUG [be71fa52] Running /usr/bin/env [ -f /home/application/www/repo/HEAD ] as [email protected]
DEBUG [be71fa52] Command: [ -f /home/application/www/repo/HEAD ]
DEBUG [be71fa52] Finished in 0.116 seconds with exit status 0 (successful).
INFO The repository mirror is at /home/application/www/repo
** Execute git:update
DEBUG [0bdd6471] Running /usr/bin/env if test ! -d /home/application/www/repo; then echo "Directory does not exist '/home/application/www/repo'" 1>&2; false; fi as [email protected]
DEBUG [0bdd6471] Command: if test ! -d /home/application/www/repo; then echo "Directory does not exist '/home/application/www/repo'" 1>&2; false; fi
DEBUG [0bdd6471] Finished in 0.114 seconds with exit status 0 (successful).
INFO [6fa1d70d] Running /usr/bin/env git remote update as [email protected]
DEBUG [6fa1d70d] Command: cd /home/application/www/repo && ( SYMFONY_ENV=prod GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/application1/git-ssh.sh /usr/bin/env git remote update )
DEBUG [6fa1d70d] Fetching origin
INFO [6fa1d70d] Finished in 1.401 seconds with exit status 0 (successful).
** Execute git:create_release
DEBUG [c772e0bf] Running /usr/bin/env if test ! -d /home/application/www/repo; then echo "Directory does not exist '/home/application/www/repo'" 1>&2; false; fi as [email protected]
DEBUG [c772e0bf] Command: if test ! -d /home/application/www/repo; then echo "Directory does not exist '/home/application/www/repo'" 1>&2; false; fi
DEBUG [c772e0bf] Finished in 0.112 seconds with exit status 0 (successful).
INFO [70568550] Running /usr/bin/env mkdir -p /home/application/www/releases/20150605153242 as [email protected]
DEBUG [70568550] Command: cd /home/application/www/repo && ( SYMFONY_ENV=prod GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/application1/git-ssh.sh /usr/bin/env mkdir -p /home/application/www/releases/20150605153242 )
INFO [70568550] Finished in 0.117 seconds with exit status 0 (successful).
INFO [37d8840c] Running /usr/bin/env git archive develop | tar -x -f - -C /home/application/www/releases/20150605153242 as [email protected]
DEBUG [37d8840c] Command: cd /home/application/www/repo && ( SYMFONY_ENV=prod GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/application1/git-ssh.sh /usr/bin/env git archive develop | tar -x -f - -C /home/application/www/releases/20150605153242 )
INFO [37d8840c] Finished in 0.693 seconds with exit status 0 (successful).
** Invoke deploy:set_current_revision (first_time)
** Execute deploy:set_current_revision
** Invoke git:set_current_revision (first_time)
** Execute git:set_current_revision
DEBUG [5f6340fb] Running /usr/bin/env if test ! -d /home/application/www/repo; then echo "Directory does not exist '/home/application/www/repo'" 1>&2; false; fi as [email protected]
DEBUG [5f6340fb] Command: if test ! -d /home/application/www/repo; then echo "Directory does not exist '/home/application/www/repo'" 1>&2; false; fi
DEBUG [5f6340fb] Finished in 0.118 seconds with exit status 0 (successful).
DEBUG [00217fb2] Running /usr/bin/env git rev-list --max-count=1 --abbrev-commit develop as [email protected]
DEBUG [00217fb2] Command: cd /home/application/www/repo && ( SYMFONY_ENV=prod GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/application1/git-ssh.sh /usr/bin/env git rev-list --max-count=1 --abbrev-commit develop )
DEBUG [00217fb2] 3adbe91
DEBUG [00217fb2] Finished in 0.124 seconds with exit status 0 (successful).
DEBUG [cbe071dc] Running /usr/bin/env if test ! -d /home/application/www/releases/20150605153242; then echo "Directory does not exist '/home/application/www/releases/20150605153242'" 1>&2; false; fi as [email protected]
DEBUG [cbe071dc] Command: if test ! -d /home/application/www/releases/20150605153242; then echo "Directory does not exist '/home/application/www/releases/20150605153242'" 1>&2; false; fi
DEBUG [cbe071dc] Finished in 0.112 seconds with exit status 0 (successful).
INFO [c6630274] Running /usr/bin/env echo "3adbe91" >> REVISION as [email protected]
DEBUG [c6630274] Command: cd /home/application/www/releases/20150605153242 && ( SYMFONY_ENV=prod /usr/bin/env echo "3adbe91" >> REVISION )
INFO [c6630274] Finished in 0.119 seconds with exit status 0 (successful).
** Invoke deploy:symlink:shared (first_time)
** Execute deploy:symlink:shared
** Invoke deploy:symlink:linked_files (first_time)
** Execute deploy:symlink:linked_files
** Invoke deploy:symlink:linked_dirs (first_time)
** Execute deploy:symlink:linked_dirs
INFO [d7271f40] Running /usr/bin/env mkdir -p /home/application/www/releases/20150605153242/app /home/application/www/releases/20150605153242/web as [email protected]
DEBUG [d7271f40] Command: ( SYMFONY_ENV=prod /usr/bin/env mkdir -p /home/application/www/releases/20150605153242/app /home/application/www/releases/20150605153242/web )
INFO [d7271f40] Finished in 0.118 seconds with exit status 0 (successful).
DEBUG [192ab209] Running /usr/bin/env [ -L /home/application/www/releases/20150605153242/app/logs ] as [email protected]
DEBUG [192ab209] Command: [ -L /home/application/www/releases/20150605153242/app/logs ]
DEBUG [192ab209] Finished in 0.115 seconds with exit status 1 (failed).
DEBUG [347133a8] Running /usr/bin/env [ -d /home/application/www/releases/20150605153242/app/logs ] as [email protected]
DEBUG [347133a8] Command: [ -d /home/application/www/releases/20150605153242/app/logs ]
DEBUG [347133a8] Finished in 0.114 seconds with exit status 1 (failed).
INFO [33f04bcc] Running /usr/bin/env ln -s /home/application/www/shared/app/logs /home/application/www/releases/20150605153242/app/logs as [email protected]
DEBUG [33f04bcc] Command: ( SYMFONY_ENV=prod /usr/bin/env ln -s /home/application/www/shared/app/logs /home/application/www/releases/20150605153242/app/logs )
INFO [33f04bcc] Finished in 0.120 seconds with exit status 0 (successful).
DEBUG [d8050aa9] Running /usr/bin/env [ -L /home/application/www/releases/20150605153242/web/uploads ] as [email protected]
DEBUG [d8050aa9] Command: [ -L /home/application/www/releases/20150605153242/web/uploads ]
DEBUG [d8050aa9] Finished in 0.113 seconds with exit status 1 (failed).
DEBUG [565a8a1d] Running /usr/bin/env [ -d /home/application/www/releases/20150605153242/web/uploads ] as [email protected]
DEBUG [565a8a1d] Command: [ -d /home/application/www/releases/20150605153242/web/uploads ]
DEBUG [565a8a1d] Finished in 0.109 seconds with exit status 1 (failed).
INFO [723e2f77] Running /usr/bin/env ln -s /home/application/www/shared/web/uploads /home/application/www/releases/20150605153242/web/uploads as [email protected]
DEBUG [723e2f77] Command: ( SYMFONY_ENV=prod /usr/bin/env ln -s /home/application/www/shared/web/uploads /home/application/www/releases/20150605153242/web/uploads )
INFO [723e2f77] Finished in 0.119 seconds with exit status 0 (successful).
** Invoke symfony:create_cache_dir (first_time)
** Execute symfony:create_cache_dir
DEBUG [f63a5e2c] Running /usr/bin/env if test ! -d /home/application/www/releases/20150605153242; then echo "Directory does not exist '/home/application/www/releases/20150605153242'" 1>&2; false; fi as [email protected]
DEBUG [f63a5e2c] Command: if test ! -d /home/application/www/releases/20150605153242; then echo "Directory does not exist '/home/application/www/releases/20150605153242'" 1>&2; false; fi
DEBUG [f63a5e2c] Finished in 0.114 seconds with exit status 0 (successful).
DEBUG [f3c048c3] Running /usr/bin/env [ -d /home/application/www/releases/20150605153242/var/cache ] as [email protected]
DEBUG [f3c048c3] Command: [ -d /home/application/www/releases/20150605153242/var/cache ]
DEBUG [f3c048c3] Finished in 0.112 seconds with exit status 0 (successful).
INFO [15357632] Running /usr/bin/env rm -rf /home/application/www/releases/20150605153242/var/cache as [email protected]
DEBUG [15357632] Command: cd /home/application/www/releases/20150605153242 && ( SYMFONY_ENV=prod /usr/bin/env rm -rf /home/application/www/releases/20150605153242/var/cache )
INFO [15357632] Finished in 0.117 seconds with exit status 0 (successful).
INFO [e0095bd8] Running /usr/bin/env mkdir -pv var/cache as [email protected]
DEBUG [e0095bd8] Command: cd /home/application/www/releases/20150605153242 && ( SYMFONY_ENV=prod /usr/bin/env mkdir -pv var/cache )
DEBUG [e0095bd8] mkdir: created directory ‘var/cache’
INFO [e0095bd8] Finished in 0.117 seconds with exit status 0 (successful).
** Invoke symfony:set_permissions (first_time)
** Execute symfony:set_permissions
** Invoke symfony:set_permissions
** Invoke deploy:updated (first_time)
** Invoke composer:install (first_time)
** Execute composer:install
** Invoke composer:run (first_time)
** Execute composer:run
DEBUG [f01988c4] Running /usr/bin/env if test ! -d /home/application/www/releases/20150605153242; then echo "Directory does not exist '/home/application/www/releases/20150605153242'" 1>&2; false; fi as [email protected]
DEBUG [f01988c4] Command: if test ! -d /home/application/www/releases/20150605153242; then echo "Directory does not exist '/home/application/www/releases/20150605153242'" 1>&2; false; fi
DEBUG [f01988c4] Finished in 0.112 seconds with exit status 0 (successful).
INFO [107f74d3] Running php /home/application/www/shared/composer.phar install --no-dev --prefer-dist --no-interaction --quiet --optimize-autoloader as [email protected]
DEBUG [107f74d3] Command: cd /home/application/www/releases/20150605153242 && ( SYMFONY_ENV=prod php /home/application/www/shared/composer.phar install --no-dev --prefer-dist --no-interaction --quiet --optimize-autoloader )
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as [email protected]: composer exit status: 1
composer stdout: Nothing written
composer stderr: Nothing written
/var/lib/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/runners/parallel.rb:16:in `rescue in block (2 levels) in execute'
/var/lib/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
SSHKit::Command::Failed: composer exit status: 1
composer stdout: Nothing written
composer stderr: Nothing written
/var/lib/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/command.rb:95:in `exit_status='
/var/lib/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:179:in `block in _execute'
/var/lib/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:133:in `tap'
/var/lib/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:133:in `_execute'
/var/lib/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:66:in `execute'
/var/lib/gems/2.1.0/gems/capistrano-composer-0.0.6/lib/capistrano/tasks/composer.rake:27:in `block (4 levels) in <top (required)>'
/var/lib/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/backends/abstract.rb:77:in `within'
/var/lib/gems/2.1.0/gems/capistrano-composer-0.0.6/lib/capistrano/tasks/composer.rake:26:in `block (3 levels) in <top (required)>'
/var/lib/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/var/lib/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:54:in `run'
/var/lib/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/runners/parallel.rb:13:in `block (2 levels) in execute'
Tasks: TOP => composer:run
The deploy has failed with an error: Exception while executing as [email protected]: composer exit status: 1
composer stdout: Nothing written
composer stderr: Nothing written
** Invoke deploy:failed (first_time)
** Execute deploy:failed
Я нахожу проблему,
Проблема:
Обычно Capistrano composer устанавливает SYMFONY_ENV как «prod», но он не экспортирует var, поэтому symfony пытается вызывать пакеты разработки, но также, когда работает инструкция установки composer, существует опция —no-dev с помощью команды command, и это вызывает проблема. В vendor / нет пакетов для разработки, но в app / AppKernel.php он пытается это сделать и вылетает с классом Not Found Error.
Решение: добавьте это в ваш файл deploy / {stage} .rb.
set :default_env, {
'SYMFONY_ENV' => 'prod'
}
Других решений пока нет …