Skip to content

Commit

Permalink
完善log信息
Browse files Browse the repository at this point in the history
  • Loading branch information
hhyo authored and lihuanhuan committed Apr 29, 2018
1 parent d77ac0d commit 09c91c5
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions sql/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
scheduler = BackgroundScheduler()
scheduler.add_jobstore(DjangoJobStore(), "default")
register_events(scheduler)
scheduler.start()
try:
scheduler.start()
logger.debug("Scheduler started!")
except SchedulerAlreadyRunningError:
logger.debug("Scheduler is already running!")


# 添加/修改sql执行任务
Expand Down Expand Up @@ -52,14 +56,18 @@ def add_sqlcronjob(request):
scheduler.add_job(execute_job, 'date', run_date=run_date, args=[workflowId, url], id=job_id,
replace_existing=True)
register_events(scheduler)
scheduler.start()
try:
scheduler.start()
logger.debug("Scheduler started!")
except SchedulerAlreadyRunningError:
logger.debug("Scheduler is already running!")
workflowDetail.status = Const.workflowStatus['tasktiming']
workflowDetail.save()
except Exception as e:
context = {'errMsg': '任务添加失败,错误信息:' + str(e)}
return render(request, 'error.html', context)
else:
logger.debug('add_sqlcronjob:' + job_id)
logger.debug('add_sqlcronjob:' + job_id + "run_date:" + run_date.strftime('%Y-%m-%d %H:%M:%S'))

return HttpResponseRedirect(reverse('sql:detail', args=(workflowId,)))

Expand Down

0 comments on commit 09c91c5

Please sign in to comment.