ruby on rails

I am using delayed_job to perform a system call. This system call invokes a Groovy script.

class Job
    def perform
        command "groovy file.groovy"
        system command
    end

    def success(job)
        # handle success
    end

    def error(job, exception)
        # handle error, exception
    end
end

This is all working perfectly but I always get back a "success" status since my groovy always exits correctly. I am currently throwing RuntimeExeptions in the Groovy Script to provoke failing job. When I call system "groovy progra.groovy" and it raises an exception (The groovy program raises an Exception), the return value of system call is, as expected false . But when doing the same via delayed_job, it never accesses the def error method but the def success method.

Do you have any advise on how delayed_job actually controls the returns of the perform method? When does it enter the error or failure hook. Unfortunately I have not found anything on this topic in the documentation.

Thanks in advance


Have you tried something like this :

def perform
    command = "groovy file.groovy"
    system command || raise "Error executing command : #{command}"
end

I'm pretty sure delayed_job wraps the perform call in a rescue block and call success or error based on any exception it catches.

链接地址: http://www.djcxy.com/p/65778.html

上一篇: 在Ruby中延迟处理作业:多少不会阻止我的路径

下一篇: 红宝石在轨道上