REAPI/daemon.py

33 lines
1.0 KiB
Python
Raw Normal View History

2024-09-29 15:43:18 +08:00
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# dm_process为keyvalue为具体指令 如call office-convert_call id=1
import time
import os
#import pprint
#import subprocess
#from gevent import monkey; monkey.patch_socket()
#import gevent
timeSleep = 15
def popen(command, bg=False):
string = command
if bg == True:
command = command + ' &'
process = os.popen(command)
output = process.read()
process.close()
return output
# 定时执行进程
def process():
# command = '/www/server/php/82/bin/phpi /www/wwwroot/mhconsole/public/index.php gateway/api.task/cron 1>/dev/null 2>&1 &'
2024-11-02 15:27:08 +08:00
command = 'php /www/wwwroot/reapi/public/index.php gateway/api.task/cron 1>/dev/null 2>&1 &'
2024-09-29 15:43:18 +08:00
check = 'ps -ef | grep gateway/api.task/cron | grep -v grep | wc -l'
i = 0
while 1:
value = int(popen(check))
if value == 0:
popen(command)
time.sleep(timeSleep)
process()