exception in initandlisten 12596 old lock file terminating

本文介绍了当遇到MongoDB启动时出现'exceptionininitandlisten12596oldlockfileterminating'错误的两种解决方案:一是删除data目录下的.lock文件;二是使用'mongod--repair'命令修复。

exception in initandlisten 12596 old lock file terminating

一般是因为非正常关闭mongod 导致的

 

解决

1.删除data目录中的.lock文件

 

如果还不行
2.mongod --repair

def monitor_usb_device(target_vendor,target_product,shell_file): print("\n****Monitor_Picocom_Device****") previous_devices = set() running_process = None # 保存当前运行的进程对象 def terminate_process(): nonlocal running_process if running_process and running_process.poll() is None: # 进程仍在运行 os.killpg(os.getpgid(running_process.pid), signal.SIGTERM) running_process = None print("Terminated running shell script.") try: while True: current_ven_ids, current_pro_ids = get_usb_device_ids() # 获取当前设备列表 current_devices = set(zip(current_ven_ids, current_pro_ids)) # 组合为元组集合 # 检查新插入的设备 for device in current_devices - previous_devices: if device[0] == hex(target_vendor) and device[1] == hex(target_product): print(f"\npicocom_device_in: VendorID={device[0]}, ProductID={device[1]}") sleep(1) print("\nStop_Old_Process...") terminate_process() sleep(1) print("\nStar_New_Process...") running_process = subprocess.Popen( ["/bin/bash", shell_file], preexec_fn=os.setsid, # 创建新进程组,便于整体终止 stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True ) print(f"Started shell_process (PID: {running_process.pid})") print("Flush_Out:", running_process.stdout) try: for line in running_process.stdout: # 逐行读取 sys.stdout.write(line) # 输出到终端 sys.stdout.flush() # 强制刷新 with open("output.log", "a") as f: f.write(line) # 写入文件 finally: running_process.wait() # 确保进程结束 # 检查已拔出的设备 for device in previous_devices - current_devices: if device[0] == hex(target_vendor) and device[1] == hex(target_product): print(f"\npicocom_device_out: VendorID={device[0]}, ProductID={device[1]}") sleep(1) print("\nStop_New_Process...") terminate_process() previous_devices = current_devices time.sleep(1) except KeyboardInterrupt: print("\nStop") except Exception as e: print(f"Error: {e}")
07-17
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值