新手问题 使用 Mina 发布,报 production.log 权限不正确,求解答?

diguage · 2014年03月07日 · 最后由 crazyunix 回复于 2014年03月07日 · 3493 次阅读

最近新起一个项目,使用Mina进行发布,在第一次发布时,总是报如下错误:

错误日志

-----> Migrating database        
        Rails Error: Unable to access log file. Please ensure that /home/dgg/newp/tmp/build-13941793351724/log/production.log exists and is chmod 0666. The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.
       [deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
-----> Precompiling asset files        
       Rails Error: Unable to access log file. Please ensure that /home/dgg/newp/tmp/build-13941793351724/log/production.log exists and is chmod 0666. The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.
       rake aborted!
       File exists - /home/dgg/newp/tmp/build-13941793351724/tmp
       /home/dgg/newp/tmp/build-13941793351724/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.17/lib/active_support/cache/file_store.rb:162:in `ensure_cache_path'
       /home/dgg/newp/tmp/build-13941793351724/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.17/lib/active_support/cache/file_store.rb:91:in `write_entry'
       /home/dgg/newp/tmp/build-13941793351724/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.17/lib/active_support/cache/strategy/local_cache.rb:140:in `write_entry'
       /home/dgg/newp/tmp/build-13941793351724/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.17/lib/active_support/cache.rb:364:in `block in write'
       /home/dgg/newp/tmp/build-13941793351724/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.17/lib/active_support/cache.rb:520:in `instrument'
       /home/dgg/newp/tmp/build-13941793351724/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.17/lib/active_support/cache.rb:362:in `write'
       /home/dgg/newp/tmp/build-13941793351724/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/caching.rb:90:in `cache_set'
       /home/dgg/newp/tmp/build-13941793351724/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/caching.rb:53:in `cache_set_hash'


Mina发布脚本如下:

require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rvm'

namespace :env do
  task :ss => [:environment] do
    set :domain, '192.168.0.1'
    set :branch, 'develop'
    set :deploy_server, 'ss'
  end
end

set :deploy_to, '/home/dgg/newp'
set :app_path, "#{deploy_to}/#{current_path}"
set :repository, 'git@[My_Git_Repon]'

set :shared_paths, ['tmp', 'log', 'config/database.yml', 'config/application.yml', 'public/uploads']
set :user, 'dgg'
set :server, ENV['to'] || default_server

invoke :"env:#{server}"
task :environment do
  invoke :'rvm:use[1.9.3]'
end

task :deploy => :environment do
  deploy do
    invoke :'git:clone'
    invoke :'deploy:link_shared_paths'
    invoke :'bundle:install'
    invoke :'rails:db_migrate'
    invoke :'rails:assets_precompile'
  end
end

我的尝试

我使用chmod 666 /home/dgg/newp/tmp/ -R赋予相应的权限,但是还是报这个错误。在 StackOverflow 上查了一下,一些解答的目录貌似固定目录。对于我的这种情况不适用。

环境描述

  • Ubuntu 12.04 64 位
  • Rails 3.2.17
  • Mina 最新版

请问:这个问题怎么破?求指点,求解答。谢谢!

@diguage 试着写个任务把权限加起来

task :setup => :environment do
  queue! %[mkdir -p "#{deploy_to}/shared/log"]
  queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/log"]
end

@zj0713001 小内 出来解决下

#1 楼 @xfstart07 还是会报错。错误如下:

-----> Precompiling asset files        
       rake aborted!
       File exists - /home/dgg/newp/tmp/build-139418135521075/tmp
       /home/dgg/newp/tmp/build-139418135521075/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.17/lib/active_support/cache/file_store.rb:162:in `ensure_cache_path'
       /home/dgg/newp/tmp/build-139418135521075/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.17/lib/active_support/cache/file_store.rb:91:in `write_entry'
       /home/dgg/newp/tmp/build-139418135521075/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.17/lib/active_support/cache/strategy/local_cache.rb:140:in `write_entry'
       /home/dgg/newp/tmp/build-139418135521075/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.17/lib/active_support/cache.rb:364:in `block in write'
       /home/dgg/newp/tmp/build-139418135521075/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.17/lib/active_support/cache.rb:520:in `instrument'
       /home/dgg/newp/tmp/build-139418135521075/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.17/lib/active_support/cache.rb:362:in `write'
       /home/dgg/newp/tmp/build-139418135521075/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/caching.rb:90:in `cache_set'
       /home/dgg/newp/tmp/build-139418135521075/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/caching.rb:53:in `cache_set_hash'
       /home/dgg/newp/tmp/build-139418135521075/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/caching.rb:24:in `cache_asset'
       /home/dgg/newp/tmp/build-139418135521075/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/index.rb:92:in `build_asset'
       /home/dgg/newp/tmp/build-139418135521075/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:169:in `find_asset'
       /home/dgg/newp/tmp/build-139418135521075/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/index.rb:60:in `find_asset'
       /home/dgg/newp/tmp/build-139418135521075/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.17/lib/sprockets/static_compiler.rb:19:in `block in compile'
       /home/dgg/newp/tmp/build-139418135521075/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:219:in `block in each_logical_path'
       /home/dgg/newp/tmp/build-139418135521075/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:206:in `block (2 levels) in each_file'
       /home/dgg/newp/tmp/build-139418135521075/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:196:in `each'
       /home/dgg/newp/tmp/build-139418135521075/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:196:in `each_entry'
       /home/dgg/newp/tmp/build-139418135521075/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:204:in `block in each_file'
       /home/dgg/newp/tmp/build-139418135521075/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:203:in `each'
       /home/dgg/newp/tmp/build-139418135521075/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:203:in `each_file'
       /home/dgg/newp/tmp/build-139418135521075/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:217:in `each_logical_path'
       /home/dgg/newp/tmp/build-139418135521075/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.17/lib/sprockets/static_compiler.rb:18:in `compile'
       /home/dgg/newp/tmp/build-139418135521075/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.17/lib/sprockets/assets.rake:56:in `internal_precompile'
       /home/dgg/newp/tmp/build-139418135521075/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.17/lib/sprockets/assets.rake:70:in `block (3 levels) in <top (required)>'
       /home/dgg/newp/tmp/build-139418135521075/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.17/lib/sprockets/assets.rake:60:in `block (3 levels) in <top (required)>'
       /home/dgg/newp/tmp/build-139418135521075/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.17/lib/sprockets/assets.rake:23:in `invoke_or_reboot_rake_task'
       /home/dgg/newp/tmp/build-139418135521075/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.17/lib/sprockets/assets.rake:29:in `block (2 levels) in <top (required)>'
       Tasks: TOP => assets:precompile:primary
       (See full trace by running task with --trace)
 !     ERROR: Deploy failed.   
-----> Cleaning up build        
       Unlinking current 
       OK 

 !     Command failed.
       Failed with status 19

@leopku 锅。。出来吧

@diguage 不是有 log 说了嘛 File exists - /home/dgg/newp/tmp/build-139418135521075/tmp

@diguage 多加一行 task :setup => :environment do queue! %[mkdir -p "#{deploy_to}/shared/log"] queue! %[mkdir -p "#{deploy_to}/shared/tmp"] queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/log"] queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/tmp"] end

需要 登录 后方可回复, 如果你还没有账号请 注册新账号