From f624779da531092a0248316832fcbdf74964b610 Mon Sep 17 00:00:00 2001 From: Marvin Zhang Date: Sat, 23 Mar 2019 21:03:27 +0800 Subject: [PATCH] fixed Issue #3 --- crawlab/routes/spiders.py | 4 ++-- crawlab/tasks/spider.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crawlab/routes/spiders.py b/crawlab/routes/spiders.py index 89881223..a885a225 100644 --- a/crawlab/routes/spiders.py +++ b/crawlab/routes/spiders.py @@ -159,7 +159,7 @@ class SpiderApi(BaseApi): db_manager.save('tasks', { '_id': job.id, 'spider_id': ObjectId(id), - 'create_ts': datetime.now(), + 'create_ts': datetime.utcnow(), 'status': TaskStatus.PENDING }) @@ -252,7 +252,7 @@ class SpiderApi(BaseApi): db_manager.save('deploys', { 'spider_id': ObjectId(id), 'node_id': node_id, - 'finish_ts': datetime.now() + 'finish_ts': datetime.utcnow() }) return { diff --git a/crawlab/tasks/spider.py b/crawlab/tasks/spider.py index cc967263..a4f2432d 100644 --- a/crawlab/tasks/spider.py +++ b/crawlab/tasks/spider.py @@ -41,7 +41,7 @@ def execute_spider(self, id: str): # create a new task db_manager.update_one('tasks', id=task_id, values={ - 'start_ts': datetime.now(), + 'start_ts': datetime.utcnow(), 'node_id': hostname, 'hostname': hostname, 'log_file_path': log_file_path, @@ -72,11 +72,11 @@ def execute_spider(self, id: str): # save task when the task is finished db_manager.update_one('tasks', id=task_id, values={ - 'start_ts': datetime.now(), + 'start_ts': datetime.utcnow(), 'node_id': hostname, 'hostname': hostname, 'log_file_path': log_file_path, - 'finish_ts': datetime.now(), + 'finish_ts': datetime.utcnow(), 'status': status }) task = db_manager.get('tasks', id=id)