0
votes

I'm folowing this link to put ruby on rails start automatically.

But I cant understand its ruby code

#!/usr/bin/env ruby
require File.expand_path("../../config/environment", __FILE__)   #1.what is this path?
STDOUT.sync = true

Stalker::job 'user.fetch_details' do |args|  #2.what is this user?
  begin
    user = User.find(args['id'])    #3.what is this id?
    user.fetch_user_details!
    rescue ActiveRecord::RecordNotFound # too fast
    Rails.logger.warn "Unable to find user ##{args['id']} - suspect too fast, requeuing"
    Stalker.enqueue('user.fetch_details', :id => args['id'])
  end
end
jobs = ARGV.shift.split(',') rescue nil
Stalker.work jobs

and conf file code in /etc/init/

  description "TweetedLinks Ruby Worker"

  # automatically start
  start on filesystem

  # working directory
  chdir /var/www/TweetedLinks/current #4.should I change this to my own dir?ie home/usr/Trail/test-app

  # command to run, with Bundler support!
  env RAILS_ENV=production
  exec bundle exec ruby script/worker.rb >> log/worker.log  #5.do i need to create this worker.log? and this script folder can be put anywhere?

  respawn

I have my rails app under home/usr/Trail/test-app

I have create a script folder under home/usr/script

I have my rvm generated under home/usr/.rvm/wrapper/test-app

How to modify this code according to my situation. and the 5 question in code comments I also very confuse.

Thanks in advance!have been stuck for month!

1
What operation system do you use?spickermann
@spickermann I use ubuntu 12.04asdjkag

1 Answers

1
votes

The easiest way would be to use foreman gem that can export Procfile to upstart, see http://ddollar.github.io/foreman/#UPSTART-EXPORT