mirror of
https://github.com/aaPanel/aaPanel.git
synced 2026-08-17 21:25:47 +02:00
1. Added Mail Marketing Automation trigger tasks 2. Added Mail Marketing Groups Import, Export, Merge 3. Added Mail Marketing Subscribers to support paste import 4. Added Mail Marketing Template Import Export Duplicate 5. Added Mail server add timed automatic reply 6. Added HTTPS Protection function for Website (disables automatic HTTP to HTTPS redirection when enabled) 7. Optimize Website Interface Button Integration 8. Optimize the response speed of WP Toolkit interface
46 lines
1.5 KiB
Python
46 lines
1.5 KiB
Python
import time
|
|
import os, sys
|
|
panelPath = '/www/server/panel/'
|
|
os.chdir(panelPath)
|
|
needed_paths=['/www/server/panel', '/www/server/panel/class','/www/server/panel/class_v2']
|
|
for path in needed_paths:
|
|
if path not in sys.path:
|
|
sys.path.insert(0,path)
|
|
import public
|
|
|
|
def task(echo):
|
|
execstr = public.GetConfigValue('setup_path') + '/cron/' + echo
|
|
public.ExecShell('chmod +x ' + execstr)
|
|
public.ExecShell('nohup ' + execstr + ' start >> ' + execstr + '.log 2>&1 &')
|
|
|
|
|
|
def run_task(echo, interval):
|
|
timestamp_file = '{}/data/{}.timestamp'.format(panelPath,echo)
|
|
start_time = time.time()
|
|
|
|
while time.time() - start_time <= 60:
|
|
try:
|
|
with open(timestamp_file, 'r') as file:
|
|
last_executed = float(file.read().strip())
|
|
except (FileNotFoundError, ValueError):
|
|
last_executed = 0
|
|
|
|
current_time = time.time()
|
|
if current_time - last_executed >= interval:
|
|
# print("任务开始执行时间: {}".format(time.strftime('%H:%M:%S')))
|
|
task(echo)
|
|
with open(timestamp_file, 'w') as file:
|
|
file.write(str(time.time()))
|
|
# 计算需要等待的时间,避免过频繁的检查
|
|
time_to_wait = interval - (current_time - last_executed)
|
|
time.sleep(max(0, time_to_wait))
|
|
|
|
if __name__ == '__main__':
|
|
if len(sys.argv) != 3:
|
|
sys.exit(1)
|
|
|
|
interval = int(sys.argv[1])
|
|
echo = sys.argv[2]
|
|
|
|
run_task(echo, interval)
|