CAPISTRANO + Whenever gems are rubbish / rails: permission denied

I have set up a production environment that deploys and works as it should. Although I ran into an auxiliary problem that I cannot understand.

I run every time I execute several cron jobs, whenever whenever the gem capistrano implementation is correctly deployed and the scripts are executed. Although inside every.log I get the following output:

/bin/bash: bin/rails: Permission denied

The script uses a runner to update from the RSS feed, this worked without incident during the previous production deployment, although I was deployed to a new server using Capistrano.

I searched and found this question , although every time I deploy, I have to make bin / rails executable (due to deploying datestamp from Capistrano). Is there a way to get Capistrano to make an executable for me when deploying? Or is there some kind of security risk of its own when creating the bin / rails executable?

+4
source share
2 answers

I managed to solve my problem with the following (namespace, including restart, included for brevity):

namespace :deploy do

 desc 'Restart application'
  task :restart do
    on roles(:app), in: :sequence, wait: 5 do
      # Passenger restart mechanism
      execute :mkdir, '-p', "#{ release_path }/tmp"
      execute :touch, current_path.join('tmp/restart.txt')
    end
  end

  after :publishing, :restart

  after :restart, :x_bin_rails do
    on roles(:web), in: :groups, limit: 3, wait: 10 do
      within release_path do
        execute :chmod, "u+x bin/rails"
      end
    end
  end

end
+3
source

So, I decided to make the bin / folder folder a public folder

#config/deploy.rb
set :linked_dirs, fetch(:linked_dirs, []).push('bin')

Then, during the next deployment, the bin / folder will be symbolically linked to shared / bin

,

cp /your_deploy_path/releases/PREV_RELEASE/bin/* /your_deploy_path/shared/bin

... , chmod ug+x shared/bin/*

Amazon EC2-linux bin ruby.exe, ruby. , .exe, Windows.

EDIT. , rails + capistrano + . Rails 5 + Capistrano > 3.6.1

  • ( -

    # bundle config --delete bin # Might have to do that
    rake rails:update:bin
    # git add bin # If your bin dir was in gitignore, remove it from there and commit it
    
  • bin dirs ( ) deploy.rb

    set :bundle_binstubs, nil 
    
  • Deploy. , bin -x

. this SO

0

All Articles