Capifony symfony2部署错误

时间:2014-08-21 06:56:23

标签: symfony deployment capifony

我真的需要有关人员的帮助。

它跟随堆栈溢出的每个帖子,但没有任何对我有用。

我尝试部署一个symfony 2.3应用程序,我发现了这个错误:

Fatal error: require(): Failed opening required '../20140821061908/app/../vendor/autoload.php' (include_path=
'.:/usr/share/pear:/usr/share/php') in ../releases/20140821061908/
app/autoload.php on line 5

以下是我的deploy.rb:

set :application, "*****"
set :domain,      "*****"
set :deploy_to,   "*****"
set :app_path,    "app"
set :web_path,    "web"

#set :repository,  "****"
set :repository,   "******"
set :user,        "*****"
set :password,    "******"



set :scm,         :git
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `subversion`, `mercurial`, `perforce`, or `none`

set :model_manager, "doctrine"
# Or: `propel`

role :web,        domain                         # Your HTTP server, Apache/etc
role :app,        domain, :primary => true       # This may be the same as your `Web` server

# General config stuff
set :keep_releases,  5
set :shared_files,      ["app/config/parameters.yml", "app/config/parameters_dev.yml", "app/config/parameters.yml"] # This stops us from having to recreate the parameters file on every deploy.
set :shared_children,   [app_path + "/logs", web_path + "/uploads"]
set :use_composer, true
set :update_vendors, true

set :branch, `git tag`.split("\n").last


set :deploy_via, :copy
#set :deploy_via, :rsync_with_remote_cache
set :update_vendors, true
set :vendors_mode, "install"

set :composer_options, "--no-dev --verbose --prefer-dist --optimize-autoloader --no-progress"


# User details for the production server
set :user, "*****"
set :use_sudo, false
ssh_options[:forward_agent] = true
ssh_options[:keys] = %w(*********)


# Run migrations before warming the cache
#before "php app/console cache:clear"
task :upload_parameters do
  origin_file = "app/config/parameters.yml"
  destination_file = latest_release + "/app/config/parameters.yml" # Notice the
  latest_release

  try_sudo "mkdir -p #{File.dirname(destination_file)}"
  top.upload(origin_file, destination_file)
end



before "deploy:share_childs", "upload_parameters","symfony:cache:warmup", "symfony:doctrine:migrations:migrate"



after "deploy" do
    run "cd ******** && php app/console cache:clear --env=prod && php app/console assetic:dump --env=prod"
end

# Be more verbose by uncommenting the following line
logger.level = Logger::MAX_LEVEL

这是我的日志:

DL

deprecated, please use Fiddle
  * 2014-08-21 12:32:33 executing `deploy'
  * 2014-08-21 12:32:33 executing `deploy:update'
 ** transaction: start
  * 2014-08-21 12:32:33 executing `deploy:update_code'
    triggering before callbacks for `deploy:update_code'
--> Updating code base with copy strategy
    executing locally: "git ls-remote https://github.com/********** HEA
D"
Username for 'https://github.com': 
Password for '******'
    command finished in 108591ms
  * getting (via checkout) revision 1fae0d14fc741d4a0c5d948f7161a1e05649a58e to
C:/Users/user/AppData/Local/Temp/20140821083421
    executing locally: git clone -q https://github.com/reynermedia/symfony C:/Us
ers/user/AppData/Local/Temp/20140821083421 && cd C:/Users/user/AppData/Local/Tem
p/20140821083421 && git checkout -q -b deploy 1fae0d14fc741d4a0c5d948f7161a1e056
49a58e
Username for 'https://github.com':
Password for '****':
    command finished in 276697ms
  * Compressing C:/Users/user/AppData/Local/Temp/20140821083421 to C:/Users/user
/AppData/Local/Temp/20140821083421.tar.gz
    executing locally: tar czf 20140821083421.tar.gz 20140821083421
    command finished in 16760ms
    servers: ["54.244.228.172"]
 ** sftp upload C:/Users/user/AppData/Local/Temp/20140821083421.tar.gz -> /tmp/2
0140821083421.tar.gz
    [54.244.228.172] /tmp/20140821083421.tar.gz
    [54.244.228.172] done
  * sftp upload complete
  * executing "cd ********/releases && tar xzf /tmp/20140821083421.tar.g
z && rm /tmp/20140821083421.tar.gz"
    servers: ["54.244.228.172"]
    [54.244.228.172] executing command
    command finished in 2800ms
  * 2014-08-21 12:53:57 executing `deploy:finalize_update'
  * executing "chmod -R g+w ********/releases/20140821083421"
    servers: ["54.244.228.172"]
    [54.244.228.172] executing command
    command finished in 872ms
--> Creating cache directory
  * executing "sh -c 'if [ -d *****/releases/20140821083421/app/cache
 ] ; then rm -rf *******/releases/20140821083421/app/cache; fi'"
    servers: ["54.244.228.172"]
    [54.244.228.172] executing command
    command finished in 778ms
  * executing "sh -c 'mkdir -p *********/releases/20140821083421/app/cach
e && chmod -R 0777 ***********/releases/20140821083421/app/cache'"
    servers: ["54.244.228.172"]
    [54.244.228.172] executing command
    command finished in 808ms
  * executing "chmod -R g+w *********/releases/20140821083421/app/cache"
    servers: ["54.244.228.172"]
    [54.244.228.172] executing command
    command finished in 805ms
  * 2014-08-21 12:54:00 executing `deploy:share_childs'
    triggering before callbacks for `deploy:share_childs'
  * 2014-08-21 12:54:00 executing `upload_parameters'
  * executing "mkdir -p ************/releases/20140821083421/app/config"
    servers: ["54.244.228.172"]
    [54.244.228.172] executing command
    command finished in 773ms
    servers: ["54.244.228.172"]
 ** sftp upload app/config/parameters.yml -> **********/releases/201408210
83421/app/config/parameters.yml
    [54.244.228.172] *********/releases/20140821083421/app/config/paramet
ers.yml
    [54.244.228.172] done
  * sftp upload complete
  * 2014-08-21 12:54:02 executing `symfony:cache:warmup'
--> Warming up cache
  * executing "sh -c 'cd ***********/releases/20140821083421 && php app/con
sole cache:warmup --env=prod --no-debug'"
    servers: ["54.244.228.172"]
    [54.244.228.172] executing command
*** [err :: 54.244.228.172] PHP Warning:  Module 'apc' already loaded in Unknown
 on line 0
*** [err :: 54.244.228.172] PHP Warning:  require(***********/releases/2014
0821083421/app/../vendor/autoload.php): failed to open stream: No such file or d
irectory in ***********/releases/20140821083421/app/autoload.php on line 5
 ** [out :: 54.244.228.172]
 ** [out :: 54.244.228.172] Warning: require(***********/releases/201408210
83421/app/../vendor/autoload.php): failed to open stream: No such file or direct
ory in /var/www/library/releases/20140821083421/app/autoload.php on line 5
*** [err :: 54.244.228.172] PHP Fatal error:  require(): Failed opening required
 '/var/www/library/releases/20140821083421/app/../vendor/autoload.php' (include_
path='.:/usr/share/pear:/usr/share/php') in **********/releases/2014082108
3421/app/autoload.php on line 5
 ** [out :: 54.244.228.172]
 ** [out :: 54.244.228.172] Fatal error: require(): Failed opening required '**********/releases/20140821083421/app/../vendor/autoload.php' (include_path=
'.:/usr/share/pear:/usr/share/php') in ***********/releases/20140821083421/
app/autoload.php on line 5
    command finished in 903ms
*** [deploy:update_code] rolling back
  * executing "rm -rf ***********/releases/20140821083421; true"
    servers: ["54.244.228.172"]
    [54.244.228.172] executing command
    command finished in 919ms
failed: "sh -c 'sh -c '\\''cd **********/releases/20140821083421 && php ap
p/console cache:warmup --env=prod --no-debug'\\'''" on 54.244.228.172

感谢@rolerbi,de deploy传递错误,似乎做得很好。 但最后它只是回滚...... 以下是我的日志

 ** [out :: 54.244.228.172] 11:55:59 [file+] **********/releases/201408220
72838/app/../web/js/compiled/min_signup.js
    command finished in 78664ms
  * 2014-08-22 11:55:42 executing `symfony:cache:warmup'
--> Warming up cache
  * executing "sh -c 'cd **********/releases/20140822072838 && php app/con
sole cache:warmup --env=prod --no-debug'"
    servers: ["54.244.228.172"]
    [54.244.228.172] executing command
*** [err :: 54.244.228.172] PHP Warning:  Module 'apc' already loaded in Unknown
 on line 0
 ** [out :: 54.244.228.172] Warming up the cache for the prod environment with d
ebug false
    command finished in 12389ms
  * executing "chmod -R g+w **********/releases/20140822072838/app/cache"
    servers: ["54.244.228.172"]
    [54.244.228.172] executing command
    command finished in 843ms
    triggering after callbacks for `symfony:cache:warmup'
  * 2014-08-22 11:55:55 executing `symfony:doctrine:migrations:migrate'
    triggering before callbacks for `symfony:doctrine:migrations:migrate'
  * executing "sh -c 'cd **********/releases/20140822072838 && php app/con
sole --no-ansi doctrine:migrations:status --env=prod --no-debug'"
    servers: ["54.244.228.172"]
    [54.244.228.172] executing command
    command finished in 1391ms
*** [deploy:update_code] rolling back
  * executing "rm -rf **********/releases/20140822072838; true"
    servers: ["54.244.228.172"]
    [54.244.228.172] executing command
    command finished in 2183ms
failed: "sh -c 'sh -c '\\''cd **********/releases/20140822072838 && php ap
p/console --no-ansi doctrine:migrations:status --env=prod --no-debug'\\'''" on ****************

2 个答案:

答案 0 :(得分:2)

before "deploy:share_childs", "upload_parameters","symfony:cache:warmup", "symfony:doctrine:migrations:migrate"

此线程强制在安装供应商之前预热缓存。替换为:

before "deploy:share_childs",  "upload_parameters"
after  "symfony:cache:warmup", "symfony:doctrine:migrations:migrate"

取代

after "deploy" do
    run "cd ******** && php app/console cache:clear --env=prod && php app/console     assetic:dump --env=prod"
end

使用

set :assets_install,      true
set :dump_assetic_assets, true

答案 1 :(得分:-1)

我被困在这一段时间,我不确定它是否完全相同。当我部署vi Capifony时,bootstrap.php.cache文件指向我的FormBundle.php文件,但在之前的版本文件夹中已不再存在。我看了一下vendor / sensio / distribution-bundle / Sensio / Bundle / DistributionBundle / Resources / bin / build_bootstrap.php中的代码,它使用的路径是realpath( DIR 。' /../../../../../../../../app') - 硬编码路径,wtf?这样做的问题是我的供应商文件夹在共享文件夹中的mySymfony设置之外,因此realpath指向没什么用处。

然而,它确实在代码中检查了一个服务器变量($ _SERVER(' argv')),所以我只是在vhosts中设置它,将其添加到文件中: SetEnv argv / var / www / njc-forms / current

希望帮助那里的人。