![](/img/trans.png)
[英]OS X lion rvm, ruby install successfully, but doesn't execute. What am I missing?
[英]Whenever ruby scheduler doesn't work, what am I missing?
無法使它工作......
在我的config / schedule.rb中,我有:
set :output, '../log/development.log'
every 5.minutes do
runner "UserWatchedRepo.update"
end
請注意日志設置,但沒有任何反應。 在我的Rails 3.0.10模型文件app / models / user_watched_repo.rb中,我得到:
class UserWatchedRepo
include Mongoid::Document
def update
conn = FaradayStack.build 'https://api.github.com'
User.all.map do |user|
nickname = user.nickname
resp = conn.get "/users/#{nickname}/watched"
resp.body.each do |repo|
user.watchlists.build( html_url: "#{repo['html_url']}",
description: "#{repo['description']}",
fork_: "#{repo['fork']}",
forks: "#{repo['forks']}",
watchers: "#{repo['watchers']}",
created_at: "#{repo['created_at']}",
pushed_at: "#{repo['pushed_at']}",
avatar_url: "#{repo['owner']['avatar_url']}" )
end
user.save!
end
end
end
任何想法 ?
謝謝盧卡
你在控制台中運行了whenever
命令嗎?
你的代碼實際上並沒有創建一個cronjob,它只是為必須轉換為實際cronjob的gem提供輸入數據。
為了得到這個工作,你必須cd
到您的應用程序根目錄,並運行以下命令:
whenever --update-crontab YOUR_APP_NAME
據我所知, YOUR_APP_NAME
不一定是您的實際應用名稱,它只是一個唯一標識符。 我認為使用您的appname避免混淆是一種很好的做法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.