| 1752 | write_log("执行任务:{}".format(task['name'])) |
| 1753 | |
| 1754 | def start(self): |
| 1755 | tip_file = '/dev/shm/.start_task.pl' |
| 1756 | start_file = '/dev/shm/bt_task_now.pl' |
| 1757 | n = 0 |
| 1758 | # 每60秒主动执行一次,当存在开始文件时,被动执行一次 |
| 1759 | while True: |
| 1760 | try: |
| 1761 | time.sleep(1) |
| 1762 | write_file(tip_file, str(int(time.time()))) |
| 1763 | n += 1 |
| 1764 | if not os.path.exists(start_file) and n < 60: |
| 1765 | continue |
| 1766 | if os.path.exists(start_file): |
| 1767 | os.remove(tip_file) |
| 1768 | n = 0 |
| 1769 | self.do_once() |
| 1770 | except: |
| 1771 | err = traceback.format_exc() |
| 1772 | write_log("bt_task任务执行失败:", err,_level='ERROR', color='red') |
| 1773 | |
| 1774 | |
| 1775 | class _TaskListService: |