0

I'm new to rails. Have spent this whole morning trying to debug this strange problem. I am trying to deploy my rails application using mina to a staging server. My server is Ubuntu/trusty32 14.04 running with Vagrant VM. And the server I'm trying to deploy to is CentOS release 6.6. Here is the deploy task from config/deploy.rb:

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'
    to :launch do
      queue  "cd #{deploy_to}/#{current_path} && RAILS_ENV=#{rails_env} bundle exec puma -t #{puma_threads} -e #{rails_env} -d -b unix://#{deploy_to}/shared#{socket_file} --pidfile #{deploy_to}/shared#{pid_file}"
      queue "sudo echo -1000 > /proc/`cat #{deploy_to}/shared#{pid_file}`/oom_score_adj"                  
    end
  end
end

And this is the error I get.

Puma starting in single mode

  • Version 2.11.0 (ruby 2.0.0-p598), codename: Intrepid Squirrel
  • Min threads: 0, max threads: 5
  • Environment: staging
  • Daemonizing...

cat: /var/www/staging/shared/tmp/pids/puma.pid: No such file or directory

cat: /var/www/staging/shared/tmp/pids/puma.pid: No such file or directory

bash: line 176: /proc//oom_score_adj: No such file or directory

! ERROR: Deploy failed.

Strange thing is if I remove the line queue "sudo echo -1000 > /proc/`cat #{deploy_to}/shared#{pid_file}`/oom_score_adj" both pid & socket files are created. I am thinking that this line is executing the before puma finishes daemoninizing and creating the pid file. But then again this same script works fine from another server.

hassansin
  • 278
  • 3
  • 9

1 Answers1

0

Putting a random sleep between the lines seem to do the trick:

queue! "cd #{deploy_to}/#{current_path} && RAILS_ENV=#{rails_env} bundle exec puma -t #{puma_threads} -e #{rails_env} -d -b unix://#{deploy_to}/shared#{socket_file} --pidfile #{deploy_to}/shared#{pid_file}"
queue! "sleep 10"
queue! "sudo echo -1000 > /proc/`cat #{deploy_to}/shared#{pid_file}`/oom_score_adj"

But open to better solution :)

hassansin
  • 278
  • 3
  • 9