2

I have just recently deployed my application to production server, but it looks that that every process I have added to my .procfile (foreman) is not started at all. Details: I am using Rails 4.0.12, foreman 0.78.0, sidekiq 3.4.2 and clockwork 1.2.0. I am using Capistrano and I have defined a task to export procfile as an upstart service on Ubuntu 14.02. But when I start the service, no background jobs are processed. When I take look at the log files of that upstart service, I just see the following:

 Your ruby version is 1.9.3, but your Gemfile specified 2.1.2

Application is running, I can see on sidekiq dashboard that nothing is processed. Based on the error message, it looks like that I am executing my procfile somehow wrong. I have tried multiple execution scenarios, but nothing seems to work. My .procfile currently looks like this:

worker: rbenv sudo bundle exec sidekiq -C config/sidekiq.yml -e production
clock: rbenv sudo bundle exec clockwork config/clock.rb

One part of exported upstart script looks like this for example:

start on starting aaa-clock
stop on stopping aaa-clock
respawn

env PORT=5100

setuid da_admin

chdir /var/www/aaa/releases/20150728172635

exec rbenv sudo bundle exec clockwork config/clock.rb

If i try the last two commands alone in bash, it works, but when i start the service "sudo service aaa start" or "rbenv sudo service aaa start", it doesn't work.

Part of deploy.rb where I am exporting my upstart service:

namespace :foreman do
  desc "Export the Procfile to Ubuntu's upstart scripts"
  task :export do
    on roles(:app) do
      within release_path do        
        execute :rbenv, "sudo bundle exec foreman export upstart /etc/init -a #{fetch(:application)} -u #{fetch(:user)} -l #{current_path}/log -f #{release_path}/Procfile"   
      end
    end
  end

  desc "Start the application services"
  task :start do
    on roles(:app) do
      execute :rbenv, "sudo service #{fetch(:application)} start"      
    end
  end

  desc "Stop the application services"
  task :stop do
    on roles(:app) do
      execute :rbenv, "sudo service #{fetch(:application)} stop"      
    end
  end

  desc "Restart the application services"
  task :restart do
    on roles(:app) do     
      execute :rbenv, "sudo service #{fetch(:application)} restart"
    end
  end
end

Does anybody has any idea what could be wrong? I suspect, that this will be some mistake in environment configuration. Thank you in advance for your time.

EDIT:

The problem was at the end in environment of the upstart script, similar problems which pointed me in the right direction were: foreman issue foreman another issue

I had to create .env file with configuration of various environment variables. Now it atleast starts (other bugs arised, but they are not related to this issue).

Example of the .env file in the root of project directory:

PATH=/home/user/.rbenv/versions/2.1.2/bin:/usr/bin
RAILS_ENV=production
HOME=/home/user
Giron
  • 350
  • 3
  • 16

0 Answers0