diff --git a/src/jobservice/pool/redis_job_wrapper.go b/src/jobservice/pool/redis_job_wrapper.go index 6beb92465..ed11a8c9b 100644 --- a/src/jobservice/pool/redis_job_wrapper.go +++ b/src/jobservice/pool/redis_job_wrapper.go @@ -40,21 +40,7 @@ func (rj *RedisJob) Run(j *work.Job) error { execContext env.JobContext ) - execContext, err = rj.buildContext(j) - if err != nil { - buildContextFailed = true - goto FAILED //no need to retry - } - - //Wrap job - runningJob = Wrap(rj.job) - defer func() { - //Close open io stream first - if closer, ok := execContext.GetLogger().(logger.Closer); ok { - closer.Close() - } - if err == nil { logger.Infof("Job '%s:%s' exit with success", j.Name, j.ID) return //nothing need to do @@ -85,6 +71,22 @@ func (rj *RedisJob) Run(j *work.Job) error { } }() + //Wrap job + runningJob = Wrap(rj.job) + + execContext, err = rj.buildContext(j) + if err != nil { + buildContextFailed = true + goto FAILED //no need to retry + } + + defer func() { + //Close open io stream first + if closer, ok := execContext.GetLogger().(logger.Closer); ok { + closer.Close() + } + }() + //Start to run rj.jobRunning(j.ID) //Inject data