【发布时间】:2014-04-07 15:04:15
【问题描述】:
我是 Capistrano 的新手,正在尝试预编译资产。输入命令cap production deploy后,我的代码成功部署在服务器上,但我的资产没有编译。下面是我的deploy.rb文件。
#SSHKit.config.command_map[:rake] = "bundle exec rake"
# config valid only for Capistrano 3.1
lock '3.1.0'
set :application, 'woi'
set :repo_url, 'git@github.com:sanjay-salunkhe/cap.git'
set :branch, "master"
set :deploy_via, :remote_cache
set :stages, ["production"]
# Default branch is :master
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }
# Default deploy_to directory is /var/www/my_app
set :deploy_to, '/home/webuser/apps/cap/'
# 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, %w{config/database.yml}
# Default value for linked_dirs is []
# set :linked_dirs, %w{bin 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
namespace :deploy do
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
# Your restart mechanism here, for example:
execute :touch, release_path.join('tmp/restart.txt')
end
end
after :publishing, :restart
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
desc 'precompiling assets..............'
task :composer_install do
on roles(:web) do
within release_path do
execute :rake, "assets:precompile RAILS_ENV=production"
end
end
end
after :publishing, 'deploy:composer_install'
end
以下是我的日志
DEBUG [cf204b99] /usr/bin/env:
DEBUG [cf204b99] rake
DEBUG [cf204b99] : No such file or directory
DEBUG [cf204b99]
cap aborted!
SSHKit::Command::Failed: rake stdout: Nothing written
rake stderr: Nothing written
/var/lib/gems/1.9.1/gems/sshkit-1.3.0/lib/sshkit/command.rb:94:in `exit_status='
/var/lib/gems/1.9.1/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:142:in `block (4 levels) in _exe
如果可能的话,请将 Capistrano 3.1 的优秀文档链接发送给我。
谢谢,
【问题讨论】:
-
请提供日志。部署时是否在日志中显示
rake assets:precompile? -
不,它不显示 rake 资产:precompile 在 revision.log 文件中的任何位置。我在我的问题中添加了 revision.log 文件内容。
-
不,我说的是部署时控制台上打印的日志。
-
不,它没有向我显示 rake 资产:在日志中的任何位置预编译。检查问题中更新的日志。
-
@UandI - 我已经更新了 deploye.rb 文件,现在我收到错误为 DEBUG [cf204b99] /usr/bin/env: DEBUG [cf204b99] rake DEBUG [cf204b99] :没有这样的文件或目录 DEBUG [cf204b99] 上限中止! .请查看我更新的问题。
标签: ruby-on-rails-3 capistrano