我有一个很好用的脚本,除了它随机无法生成新文件......
这是代码:
...
file_log_path = File.join(Rails.root, 'log', "xls_import_#{Time.now.to_i}.log")
@log = File.new(file_log_path, 'w+')
....
这是delayed_job.log中的错误
2012-12-21T18:18:41+0100: [Worker(delayed_job host:webserver2.netbanana.it pid:24482)] LoadDataFromCsv failed with Errno::ENOENT: No such file or directory - /var/www/rails/myapp/releases/20121210093945/log/xls_import_1356110321.log - 0 failed attempts
2012-12-21T18:18:41+0100: [Worker(delayed_job host:webserver2.netbanana.it pid:24482)] PERMANENTLY removing LoadDataFromCsv because of 1 consecutive failures.
其他时候,它有效!有人可以帮助我吗?
- 编辑:
好吧...似乎 Rails.root 使用了错误的部署路径...实际上 /var/www/rails/myapp/releases/20121210093945 不存在。
但是,正如我所说,脚本有时可以工作,有时不能......如果我重新加载延迟作业,我的脚本会工作一些,然后开始失败。