2016-11-23 7 views
0

capistrano를 사용하여 응용 프로그램 배포를 자동화하려고합니다. 나는 s3 마운트 및 마운트 해제 레시피를 제외한 모든 작업을 거의 완료했습니다.Capistrano를 사용하는 Ruby on Rails 서버의 탑재 지점 오류

내가 작성한 조리법은 다음과 같습니다. 특정 조건에서 작동하며 특정 조건에서 작동하지 않습니다. 하지만 수동으로 서버에 로그인하여 직접 실행하면 제조법에 사용되는 명령이 실행됩니다. 나 자신 서버에서 S3를 장착 한 경우

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 

나는 fusermount -u를 사용하여 카피 스트라 노에서 S3 마운트 해제 수 있어요.

마찬가지로 서버에서 s3을 직접 마운트 해제 한 경우 mount s3 from capistrano 수 있습니다.

나는 모든 명령을 cc 사용자으로 실행 중입니다. 나는 왜 아직도 다음과 같은 오류가 발생하는지 이해하지 못합니다. 로그에서 공개/시스템이 마운트 포인트가 아니라는 것을 알 수 있지만 그 지점부터는 이동할 수 없습니다. mountpoint "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' 

답변

0

raise_on_non_zero_exit: false 옵션이 수정되었습니다. 실제로 출력이 없으면 캡쳐 오류가 발생합니다.

result = capture "cd #{code_folder} && mountpoint public/system" , raise_on_non_zero_exit: false