简体   繁体   中英

Run ruby on rails on upstart

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!

最简单的方法是使用可以将Procfile导出到暴发户的领班宝石,请参阅http://ddollar.github.io/foreman/#UPSTART-EXPORT

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM