[英]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/ 和conf文件代码在/ 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 我在home / usr / Trail / test-app下有我的rails应用程序
I have create a script folder under home/usr/script 我在home / usr / script下创建了一个脚本文件夹
I have my rvm generated under home/usr/.rvm/wrapper/test-app 我在home / usr / .rvm / wrapper / test-app下生成了我的rvm
How to modify this code according to my situation. 如何根据我的情况修改此代码。 and the 5 question in code comments I also very confuse. 和代码注释中的5个问题我也很困惑。
Thanks in advance!have been stuck for month! 在此先感谢您!已经停留了一个月!
最简单的方法是使用可以将Procfile导出到暴发户的领班宝石,请参阅http://ddollar.github.io/foreman/#UPSTART-EXPORT
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.