From 1cc54d3754d1f5da7b51db8414cfafa856c157a1 Mon Sep 17 00:00:00 2001 From: wangwenyan Date: Thu, 8 Mar 2018 15:58:06 +0800 Subject: [PATCH] =?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):