From 1cc54d3754d1f5da7b51db8414cfafa856c157a1 Mon Sep 17 00:00:00 2001 From: wangwenyan Date: Thu, 8 Mar 2018 15:58:06 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E6=B7=BB=E5=8A=A0pid=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PriceSystem/CalcCmdReceiver.py | 6 ++++++ PriceSystem/CalcCmdSender.py | 2 +- PriceSystem/CalcSpeedMonitor.py | 3 +-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/PriceSystem/CalcCmdReceiver.py b/PriceSystem/CalcCmdReceiver.py index b9bdce7..497dd90 100644 --- a/PriceSystem/CalcCmdReceiver.py +++ b/PriceSystem/CalcCmdReceiver.py @@ -7,6 +7,7 @@ import sell_price import fangjia import datetime import pytz +import os QUEUE = "calc_cmd" redis_pool = redis.ConnectionPool(host=config.get_redis_host(), port=6379, db=config.get_redis_db()) @@ -47,6 +48,11 @@ def format_cmd(cmd): if __name__ == "__main__": + pid_file = open("/var/run/price.sys.pid", "w") + pid_file.write(str(os.getpid())) + pid_file.flush() + pid_file.close() + pro_num = config.get_worker_num() pool = multiprocessing.Pool(processes=pro_num) for pid in range(0, pro_num): diff --git a/PriceSystem/CalcCmdSender.py b/PriceSystem/CalcCmdSender.py index 9302d7e..972ef16 100644 --- a/PriceSystem/CalcCmdSender.py +++ b/PriceSystem/CalcCmdSender.py @@ -23,7 +23,7 @@ client = redis.Redis(connection_pool=redisPool) def get_district(): seaweeds = [] keys = {"city": 1, "region": 1, "name": 1, "_id": 0} - for dis in fangjia.get_collection("fangjia", "seaweed").find({"cat": "district", "status": 0, "city": "上海"}, keys): + for dis in fangjia.get_collection("fangjia", "seaweed").find({"cat": "district", "status": 0, "city": "合肥"}, keys): dis["weekend"] = datetime.strptime("2018-03-11", "%Y-%m-%d") seaweeds.append(dis) diff --git a/PriceSystem/CalcSpeedMonitor.py b/PriceSystem/CalcSpeedMonitor.py index b610e6a..767d0f3 100644 --- a/PriceSystem/CalcSpeedMonitor.py +++ b/PriceSystem/CalcSpeedMonitor.py @@ -13,8 +13,7 @@ def monitor(pname): while True: pre_counter = client.llen(QUEUE) time.sleep(60) - print(pname + "#####################################:".zfill(100) + str( - pre_counter - client.llen(QUEUE)) + "/min") + print(pname + "#####################################:".zfill(100) + str(pre_counter - client.llen(QUEUE)) + "/min") def format_cmd(cmd): From 050a804c9d21ca82cf8a9d7b8c121ba6eb2443a0 Mon Sep 17 00:00:00 2001 From: lg <290328566@qq.com> Date: Thu, 8 Mar 2018 15:59:01 +0800 Subject: [PATCH 02/10] status:102 --- PriceSystem/sell_price/zhuge0118A.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/PriceSystem/sell_price/zhuge0118A.py b/PriceSystem/sell_price/zhuge0118A.py index 3ba7dba..91124e6 100644 --- a/PriceSystem/sell_price/zhuge0118A.py +++ b/PriceSystem/sell_price/zhuge0118A.py @@ -1305,11 +1305,11 @@ def out_put_price(ct, rl, lk, weekend): pt.replace_one( - {"city": ct, "region": rl, "district_name": p[0], "weekend": weekend}, + {"city": ct, "region": rl, "district_name": p[0], "calc_date": weekend}, - {"city": ct, "region": rl, "district_name": p[0], "c_date": c_date, 'status': int(0), - 'remark': 'week', 'category': 'sell', 'weekend': weekend, 'priority': int(0), - 'problem': None, + {"city": ct, "region": rl, "district_name": p[0], "c_date": c_date, 'status': int(102), + 'remark': 'week', 'category': 'sell', "calc_date": weekend, 'priority': int(0), + 'problem': None, "calc_type" : int(0) }, True ) @@ -1330,10 +1330,10 @@ def out_put_price(ct, rl, lk, weekend): else: pt.replace_one( - {"city": ct, "region": rl, "district_name": p[0], "weekend": weekend}, + {"city": ct, "region": rl, "district_name": p[0], "calc_date": weekend}, - {"city": ct, "region": rl, "district_name": p[0], "c_date": c_date, 'status': int(1), - 'remark': 'week', 'category': 'sell', 'weekend': weekend, 'priority': int(0), - 'problem': mm[0], + {"city": ct, "region": rl, "district_name": p[0], "c_date": c_date, 'status': int(3), + 'remark': 'week', 'category': 'sell', "calc_date": weekend, 'priority': int(0), + 'problem': mm[0], "calc_type" : int(0) }, True ) \ No newline at end of file From e06483bbf83ce380afa4070f1170bc1f8e565b64 Mon Sep 17 00:00:00 2001 From: wangwenyan Date: Thu, 8 Mar 2018 16:31:25 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PriceSystem/CalcCmdReceiver.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/PriceSystem/CalcCmdReceiver.py b/PriceSystem/CalcCmdReceiver.py index 497dd90..d38f31f 100644 --- a/PriceSystem/CalcCmdReceiver.py +++ b/PriceSystem/CalcCmdReceiver.py @@ -55,8 +55,15 @@ if __name__ == "__main__": pro_num = config.get_worker_num() pool = multiprocessing.Pool(processes=pro_num) + pool.terminate() for pid in range(0, pro_num): pool.apply_async(worker, ()) pool.close() logger.info("均价系统启动成功") + while True: + if os.path.exists("/var/run/price.sys.stop"): + pool.terminate() + break pool.join() + if os.path.exists("/var/run/price.sys.stop"): + os.remove("/var/run/price.sys.stop") \ No newline at end of file From eabf2878eef49dc13c43afd22f321b765c5536f3 Mon Sep 17 00:00:00 2001 From: wangwenyan Date: Thu, 8 Mar 2018 16:32:28 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PriceSystem/CalcCmdReceiver.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/PriceSystem/CalcCmdReceiver.py b/PriceSystem/CalcCmdReceiver.py index d38f31f..6bad4f3 100644 --- a/PriceSystem/CalcCmdReceiver.py +++ b/PriceSystem/CalcCmdReceiver.py @@ -48,11 +48,6 @@ def format_cmd(cmd): if __name__ == "__main__": - pid_file = open("/var/run/price.sys.pid", "w") - pid_file.write(str(os.getpid())) - pid_file.flush() - pid_file.close() - pro_num = config.get_worker_num() pool = multiprocessing.Pool(processes=pro_num) pool.terminate() @@ -66,4 +61,4 @@ if __name__ == "__main__": break pool.join() if os.path.exists("/var/run/price.sys.stop"): - os.remove("/var/run/price.sys.stop") \ No newline at end of file + os.remove("/var/run/price.sys.stop") From d0d88de9fdd8f58a8cbaab1623f09c108783a6b3 Mon Sep 17 00:00:00 2001 From: wangwenyan Date: Thu, 8 Mar 2018 16:37:18 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=AE=97=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PriceSystem/CalcCmdReceiver.py | 3 ++- PriceSystem/config/__init__.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/PriceSystem/CalcCmdReceiver.py b/PriceSystem/CalcCmdReceiver.py index 6bad4f3..39981ff 100644 --- a/PriceSystem/CalcCmdReceiver.py +++ b/PriceSystem/CalcCmdReceiver.py @@ -50,7 +50,6 @@ if __name__ == "__main__": pro_num = config.get_worker_num() pool = multiprocessing.Pool(processes=pro_num) - pool.terminate() for pid in range(0, pro_num): pool.apply_async(worker, ()) pool.close() @@ -59,6 +58,8 @@ if __name__ == "__main__": if os.path.exists("/var/run/price.sys.stop"): pool.terminate() break + else: + time.sleep(3) pool.join() if os.path.exists("/var/run/price.sys.stop"): os.remove("/var/run/price.sys.stop") diff --git a/PriceSystem/config/__init__.py b/PriceSystem/config/__init__.py index 8862b15..b6539c8 100644 --- a/PriceSystem/config/__init__.py +++ b/PriceSystem/config/__init__.py @@ -8,7 +8,7 @@ def get_logging_config(): def get_worker_num(): - return 30 + return 2 def get_redis_host(): From e72036422b4b211f9d5b94678505a9e83f7c9958 Mon Sep 17 00:00:00 2001 From: wangwenyan Date: Thu, 8 Mar 2018 16:41:22 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=BF=9B=E7=A8=8B?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PriceSystem/config/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PriceSystem/config/__init__.py b/PriceSystem/config/__init__.py index b6539c8..c9a8af5 100644 --- a/PriceSystem/config/__init__.py +++ b/PriceSystem/config/__init__.py @@ -8,7 +8,7 @@ def get_logging_config(): def get_worker_num(): - return 2 + return 80 def get_redis_host(): From 8e0b9fe97f916bb8c333448b0832247eeb2c2bb9 Mon Sep 17 00:00:00 2001 From: wangwenyan Date: Thu, 8 Mar 2018 16:50:39 +0800 Subject: [PATCH 07/10] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PriceSystem/CalcCmdReceiver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PriceSystem/CalcCmdReceiver.py b/PriceSystem/CalcCmdReceiver.py index 39981ff..f5b3cd7 100644 --- a/PriceSystem/CalcCmdReceiver.py +++ b/PriceSystem/CalcCmdReceiver.py @@ -60,6 +60,6 @@ if __name__ == "__main__": break else: time.sleep(3) - pool.join() if os.path.exists("/var/run/price.sys.stop"): os.remove("/var/run/price.sys.stop") + pool.join() From f566ccd3404092299e7c39286aa043c26c91a1b9 Mon Sep 17 00:00:00 2001 From: wangwenyan Date: Thu, 8 Mar 2018 16:57:14 +0800 Subject: [PATCH 08/10] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PriceSystem/CalcCmdReceiver.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PriceSystem/CalcCmdReceiver.py b/PriceSystem/CalcCmdReceiver.py index f5b3cd7..a27d5a8 100644 --- a/PriceSystem/CalcCmdReceiver.py +++ b/PriceSystem/CalcCmdReceiver.py @@ -47,7 +47,8 @@ def format_cmd(cmd): if __name__ == "__main__": - + if os.path.exists("/var/run/price.sys.stop"): + os.remove("/var/run/price.sys.stop") pro_num = config.get_worker_num() pool = multiprocessing.Pool(processes=pro_num) for pid in range(0, pro_num): From 97173287958f7e8b1b02f77f73c555faafe222a9 Mon Sep 17 00:00:00 2001 From: wangwenyan Date: Thu, 8 Mar 2018 17:36:02 +0800 Subject: [PATCH 09/10] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PriceSystem/CalcCmdReceiver.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/PriceSystem/CalcCmdReceiver.py b/PriceSystem/CalcCmdReceiver.py index a27d5a8..c6191d8 100644 --- a/PriceSystem/CalcCmdReceiver.py +++ b/PriceSystem/CalcCmdReceiver.py @@ -47,8 +47,8 @@ def format_cmd(cmd): if __name__ == "__main__": - if os.path.exists("/var/run/price.sys.stop"): - os.remove("/var/run/price.sys.stop") + if os.path.exists("/var/run/price/price.sys.stop"): + os.remove("/var/run/price/price.sys.stop") pro_num = config.get_worker_num() pool = multiprocessing.Pool(processes=pro_num) for pid in range(0, pro_num): @@ -56,11 +56,11 @@ if __name__ == "__main__": pool.close() logger.info("均价系统启动成功") while True: - if os.path.exists("/var/run/price.sys.stop"): + if os.path.exists("/var/run/price/price.sys.stop"): pool.terminate() break else: time.sleep(3) - if os.path.exists("/var/run/price.sys.stop"): - os.remove("/var/run/price.sys.stop") + if os.path.exists("/var/run/price/price.sys.stop"): + os.remove("/var/run/price/price.sys.stop") pool.join() From cf08bfcd7e80bfa290da91f3654ae022ea3d3a6f Mon Sep 17 00:00:00 2001 From: wangwenyan Date: Thu, 8 Mar 2018 18:11:48 +0800 Subject: [PATCH 10/10] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PriceSystem/CalcCmdReceiver.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/PriceSystem/CalcCmdReceiver.py b/PriceSystem/CalcCmdReceiver.py index c6191d8..ab0d3b7 100644 --- a/PriceSystem/CalcCmdReceiver.py +++ b/PriceSystem/CalcCmdReceiver.py @@ -47,8 +47,10 @@ def format_cmd(cmd): if __name__ == "__main__": - if os.path.exists("/var/run/price/price.sys.stop"): - os.remove("/var/run/price/price.sys.stop") + user_home = os.path.expanduser('~') + lock_file = user_home + "/price.sys.stop" + if os.path.exists(lock_file): + os.remove(lock_file) pro_num = config.get_worker_num() pool = multiprocessing.Pool(processes=pro_num) for pid in range(0, pro_num): @@ -56,11 +58,11 @@ if __name__ == "__main__": pool.close() logger.info("均价系统启动成功") while True: - if os.path.exists("/var/run/price/price.sys.stop"): + if os.path.exists(lock_file): pool.terminate() break else: time.sleep(3) - if os.path.exists("/var/run/price/price.sys.stop"): - os.remove("/var/run/price/price.sys.stop") + if os.path.exists(lock_file): + os.remove(lock_file) pool.join()