添加pid文件
This commit is contained in:
@@ -7,6 +7,7 @@ import sell_price
|
|||||||
import fangjia
|
import fangjia
|
||||||
import datetime
|
import datetime
|
||||||
import pytz
|
import pytz
|
||||||
|
import os
|
||||||
|
|
||||||
QUEUE = "calc_cmd"
|
QUEUE = "calc_cmd"
|
||||||
redis_pool = redis.ConnectionPool(host=config.get_redis_host(), port=6379, db=config.get_redis_db())
|
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__":
|
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()
|
pro_num = config.get_worker_num()
|
||||||
pool = multiprocessing.Pool(processes=pro_num)
|
pool = multiprocessing.Pool(processes=pro_num)
|
||||||
for pid in range(0, pro_num):
|
for pid in range(0, pro_num):
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ client = redis.Redis(connection_pool=redisPool)
|
|||||||
def get_district():
|
def get_district():
|
||||||
seaweeds = []
|
seaweeds = []
|
||||||
keys = {"city": 1, "region": 1, "name": 1, "_id": 0}
|
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")
|
dis["weekend"] = datetime.strptime("2018-03-11", "%Y-%m-%d")
|
||||||
seaweeds.append(dis)
|
seaweeds.append(dis)
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,7 @@ def monitor(pname):
|
|||||||
while True:
|
while True:
|
||||||
pre_counter = client.llen(QUEUE)
|
pre_counter = client.llen(QUEUE)
|
||||||
time.sleep(60)
|
time.sleep(60)
|
||||||
print(pname + "#####################################:".zfill(100) + str(
|
print(pname + "#####################################:".zfill(100) + str(pre_counter - client.llen(QUEUE)) + "/min")
|
||||||
pre_counter - client.llen(QUEUE)) + "/min")
|
|
||||||
|
|
||||||
|
|
||||||
def format_cmd(cmd):
|
def format_cmd(cmd):
|
||||||
|
|||||||
Reference in New Issue
Block a user