Rails delayed job referring to old release
I have a project running on Rails 4.2 and using delayed_job (4.0.6) for my background jobs. I've had an issue now for a couple of weeks where the video encoding fails when it looks for the file to process. The error message contains an old release path that has already been removed a while ago by Capistrano (3.4.0).
No such file or directory @ rb_sysopen - /var/www/apps/<app>/releases/20150906031337/static/post_assets/videos/000/436/600/original.mov
Capistrano will remove old releases automatically which is fine (I keep 5 releases), but I am restarting delayed_job on every deployment. I have the pids in a shared folder and they match up with ones I get when I run ps -ef | grep delayed_job
ps -ef | grep delayed_job
after deployment.
I run 2 workers ( set :delayed_job_workers, 2
) and I'm using 'capistrano3-delayed-job' (1.4.0) for the deployment formulas.
I do have a lot of jobs in the queue when restarting, but it's not consistent with a video encoding job running at that time that could be interfering or something (I do keep 5 releases after all, so even if the job is running on the second last one, the folder should still exist). There are a lot of smaller jobs though which might be running at the time of deployment, but DJ should be able to handle that and restart gracefully anyway right?
It seems that workers are still lingering somehow, or am I missing something else?
On restarting delayed job workers on every deployment and poiting to latest release must be solving this.
There's a gem for this
capistrano3-delayed-job
If you don't want to use gem follow for complete info.
https://github.com/collectiveidea/delayed_job/wiki/Delayed-Job-tasks-for-Capistrano-3#if-you-dont-want-to-use-a-gem
Also refer if needed https://github.com/imnithin/capistrano3
If these tasks are not supported due to version mismatch, execute custom command from cap3.
namespace :deploy do
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
# Your restart mechanism here, for example:
execute :touch, release_path.join('tmp/restart.txt')
execute "cd '#{release_path}' && RAILS_ENV=#{fetch(rails_env)} script/delayed_job -n 2 restart"
end
end
end
链接地址: http://www.djcxy.com/p/65786.html
上一篇: 不接收Rails actionmailer和延迟作业的邮件
下一篇: Rails推迟了工作,指的是旧版本