0
我正在嘗試使用Capistrano自動部署應用程序。除了s3安裝和卸載配方之外,我幾乎完成了所有任務。在使用Capistrano的Ruby on Rails服務器上發生Mountpoint錯誤
這是我寫的配方,它在某些條件下工作,並且在某些條件下不起作用。但是,如果我手動登錄到服務器並自己執行它們,配方中使用的命令將運行。
desc "Mounting S3 for the first time"
task :mounting_s3 do
on %w(uat2_sub1 uat2_main), in: :sequence, wait: 5 do |host|
as 'cc' do
within '/var/www/test_cap/current' do
code_folder = "/var/www/test_cap/current"
path = "/var/www/test_cap/current/public/system"
unmount_path = "/var/www/test_cap/shared/public/system"
# check first if public/system exists
puts "** Checking if public/system folder exists on #{host}"
if test("[ -d #{path} ]")
puts "** public/system folder exists.."
puts "** Checking if S3 is mounted"
result = execute! "mountpoint #{path}"
puts "result #{result}"
if result.match('is a mountpoint') != nil
puts "** S3 is mounted at #{path} on #{host}"
puts "** unmounting s3 at #{unmount_path}"
execute! "fusermount -u #{unmount_path}"
puts "** s3 unmounted at #{unmount_path} on #{host}"
elsif result.match('is not a mountpoint') != nil
puts "** #{path} is not a mountpoint on #{host}"
end
else
puts "** public/system folder does not exists.."
puts "** Mounting S3"
execute! "cd #{code_folder} && s3fs cc-system-uat #{path}"
end
end
end
end
end
我能夠卸載S3從Capistrano的使用fusermount -u
如果我從服務器安裝S3自己。
同樣我可以安裝s3從capistrano如果我有從服務器自己卸載s3。
我運行的所有命令爲cc用戶。我仍然不明白爲什麼我會收到以下錯誤。在日誌中可以看到公共/系統不是一個掛載點,但我無法從這一點前進。因爲我想將掛載點「public/system」的結果存儲在一個變量中,然後執行不同的任務。
** Invoke bundler:map_bins (first_time)
** Execute bundler:map_bins
** Invoke deploy:set_rails_env (first_time)
** Execute deploy:set_rails_env
** Invoke deploy:set_linked_dirs (first_time)
** Execute deploy:set_linked_dirs
** Invoke deploy:set_rails_env
** Invoke deploy:mounting_s3 (first_time)
** Execute deploy:mounting_s3
** Checking if public/system folder exists on uat2_sub1
** public/system folder exists..
** Checking if S3 is mounted
00:00 deploy:mounting_s3
01 mountpoint /var/www/test_cap/current/public/system
01 /var/www/test_cap/current/public/system is not a mountpoint
cap aborted!
Exception while executing on host uat2_sub1: mountpoint /var/www/test_cap/current/public/system exit status: 1
mountpoint /var/www/test_cap/current/public/system stdout: /var/www/test_cap/current/public/system is not a mountpoint
mountpoint /var/www/test_cap/current/public/system stderr: Nothing written
/home/xyz/.rvm/gems/ruby-2.1.0/gems/sshkit-1.11.4/lib/sshkit/runners/sequential.rb:31:in `rescue in run_backend'