我有一個rails runner
命令,它對Heroku Scheduler
不起作用。Rails Runner無法在Heroku Scheduler上工作
我的Rails應用程序有符文罰款作爲一個獨立的腳本在我的開發環境獨立Ruby腳本:
#!/usr/bin/env ruby
require 'aws-sdk'
#provide AWS credentials
s3 = Aws::S3::Resource.new(
region: 'us-east-1',
access_key_id: 'my_key',
secret_access_key: 'my_secret_key'
)
#download files from S3
s3.bucket('my_bucket').object('path/in/s3/test.csv').get(response_target: 'lib/assets/data/test.csv')
在開發中,我可以通過使用whenever
寶石以及運行它通過cron
運行從控制檯使用load
命令。但它不會運行使用Heroku Scheduler
。我曾嘗試在調度許多不同的任務:
rails runner "lib/assets/ruby/s3download.rb" --a MY_APP
rails runner "lib/assets/ruby/s3download.rb" -a MY_APP
rails runner "lib/assets/ruby/s3download.rb" --app MY_APP
rails runner "lib/assets/ruby/s3download.rb" -app MY_APP
rails runner "lib/assets/ruby/s3download.rb"
我不斷收到來自heroku logs --ps scheduler
相同的輸出:
015-05-21T03:02:59.499850+00:00 heroku[scheduler.3070]: State changed from starting to up
2015-05-21T03:03:02.735002+00:00 heroku[scheduler.3942]: State changed from up to complete
2015-05-21T03:03:02.722488+00:00 heroku[scheduler.3942]: Process exited with status 0
我在做什麼錯?
沒有真正回答你的問題,但因爲它只是Ruby代碼,所以爲什麼不使用rake任務而不是bash腳本? – aledalgrande