GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: add startup integrity audit and repair Feishu launchers · Innerpeace1990/GenericAgent@5c1448c

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • memory
    • scheduled_task_sop.md
  • scripts
    • feishu_health_check.py
    • feishu_health_check.vbs
    • run_startup_integrity_audit.ps1
    • start_feishu_agent.vbs
    • validate_startup_items.ps1
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎memory/scheduled_task_sop.md‎

Copy file name to clipboardExpand all lines: memory/scheduled_task_sop.md
+11-5Lines changed: 11 additions & 5 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
## 版本信息
22

3-
- 版本:v1.0
3+
- 版本:v1.1
44
- 创建时间:2026-07-06
5-
- 最后验证:2026-07-06
5+
- 最后验证:2026-07-30
66
- 状态:有效
77
- 替代方案:无
8+
- 变更记录:
9+
- v1.1(2026-07-30):验证当前环境不存在可导入的 `scheduler` 模块;补充 Windows Task Scheduler 作为系统级定时巡检的可验证执行器。
810

911
---
1012

1113
# 定时任务 SOP
1214

15+
> **适用环境**:GA code root 下的 `sche_tasks` 调度体系;Windows Task Scheduler 备选方案仅适用于 Windows 10/11,非 Windows 环境必须使用 cron/systemd timer 等等价执行器。
16+
1317
目录:`../sche_tasks/` 放任务定义JSON,`../sche_tasks/done/` 放执行报告
1418

1519
## 任务JSON格式(*.json)
@@ -27,9 +31,11 @@ max_delay_hours(可选,默认6):超过schedule多少小时后不再触
2731
5. 执行完毕后将报告写入上述路径(scheduler靠此文件判断今天已执行)
2832

2933
## 日志与监控
30-
- scheduler自动写日志到 `sche_tasks/scheduler.log`(触发/跳过/错误)
31-
- `scheduler.health_check()` 返回所有任务状态列表(HEALTHY/OVERDUE/DISABLED/NEVER_RUN/ERROR)
32-
- JSON解析错误、schedule格式错误、未知repeat类型均会记录日志
34+
- GA scheduler可用时自动写日志到 `sche_tasks/scheduler.log`(触发/跳过/错误)。
35+
- 2026-07-30 验证:当前环境无可导入的 `scheduler` 模块,禁止默认执行 `import scheduler` 或 `scheduler.health_check()`。
36+
- 若需系统级定时巡检,可使用 Windows Task Scheduler;任务必须放在 `\GenericAgent\` 路径下。
37+
- Windows Task 注册后必须手动触发一次,并用 `Get-ScheduledTaskInfo` 确认 `LastTaskResult -eq 0`;只注册不验证不算完成。
38+
- JSON解析错误、schedule格式错误、未知repeat类型应记录日志。
3339

3440
## 注意
3541
- once类型:执行一次后冷却100年(实际效果为永久跳过)
Collapse file

‎scripts/feishu_health_check.py‎

Copy file name to clipboard
+86Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Feishu Agent Health Check (Watchdog)
2+
import os, subprocess, time, sys, datetime
3+
4+
ROOT = r"D:\generic-agent"
5+
LOG_FILE = os.path.join(ROOT, "logs", "feishu_health.log")
6+
FSAPP_LOG = os.path.join(ROOT, "logs", "fsapp.log")
7+
PYTHON = r"C:\Users\wangx\AppData\Local\Programs\Python\Python312\python.exe"
8+
START_PS = os.path.join(ROOT, "scripts", "start_feishu_agent.ps1")
9+
10+
def log(msg):
11+
ts = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
12+
line = f"{ts} [INFO] {msg}"
13+
try:
14+
with open(LOG_FILE, "a", encoding="utf-8") as f:
15+
f.write(line + "\n")
16+
except Exception as e:
17+
print(f"log error: {e}")
18+
print(line)
19+
20+
def find_fsapp():
21+
r = subprocess.run('wmic process where "name=\'python.exe\'" get processid,commandline /format:csv',
22+
capture_output=True, text=True, shell=True)
23+
for line in r.stdout.splitlines():
24+
if 'fsapp.py' in line:
25+
parts = line.split(',')
26+
if parts:
27+
return parts[-1].strip()
28+
return None
29+
30+
def has_443_connection(pid):
31+
r = subprocess.run(f'netstat -ano | findstr {pid}', capture_output=True, text=True, shell=True)
32+
for line in r.stdout.splitlines():
33+
if ':443' in line and 'ESTABLISHED' in line:
34+
return True
35+
return False
36+
37+
def restart_fsapp():
38+
log("Restarting fsapp...")
39+
# Kill old fsapp processes
40+
r = subprocess.run('wmic process where "name=\'python.exe\'" get processid,commandline /format:csv',
41+
capture_output=True, text=True, shell=True)
42+
for line in r.stdout.splitlines():
43+
if 'fsapp.py' in line:
44+
pid = line.split(',')[-1].strip()
45+
try:
46+
subprocess.run(f'taskkill /pid {pid} /f', capture_output=True, shell=True)
47+
log(f"Killed old fsapp PID {pid}")
48+
except Exception as e:
49+
log(f"Failed to kill {pid}: {e}")
50+
time.sleep(2)
51+
# Start via PowerShell script
52+
subprocess.Popen(['powershell', '-ExecutionPolicy', 'Bypass', '-File', START_PS],
53+
cwd=ROOT)
54+
log("Restart command issued")
55+
56+
def already_running():
57+
r = subprocess.run('wmic process where "name=\'python.exe\'" get processid,commandline /format:csv',
58+
capture_output=True, text=True, shell=True)
59+
count = 0
60+
for line in r.stdout.splitlines():
61+
if 'feishu_health_check.py' in line:
62+
count += 1
63+
return count > 1
64+
65+
def main():
66+
if already_running():
67+
print("Health check already running, exit")
68+
return
69+
log("Health check started")
70+
while True:
71+
try:
72+
pid = find_fsapp()
73+
if not pid:
74+
log("fsapp not running, trigger restart")
75+
restart_fsapp()
76+
elif not has_443_connection(pid):
77+
log(f"fsapp PID {pid} alive but no 443 connection, restart")
78+
restart_fsapp()
79+
else:
80+
log(f"fsapp PID {pid} healthy")
81+
except Exception as e:
82+
log(f"Health check exception: {e}")
83+
time.sleep(60)
84+
85+
if __name__ == "__main__":
86+
main()
Collapse file

‎scripts/feishu_health_check.vbs‎

Copy file name to clipboard
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Set WshShell = CreateObject("WScript.Shell")
2+
WshShell.Run """C:\Users\wangx\AppData\Local\Programs\Python\Python312\python.exe"" ""D:\generic-agent\scripts\feishu_health_check.py""", 0, False
Collapse file

‎scripts/run_startup_integrity_audit.ps1‎

Copy file name to clipboard
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Daily wrapper for Startup Item Integrity Audit.
2+
$ErrorActionPreference = 'Stop'
3+
$Root = 'D:\generic-agent'
4+
$Validator = Join-Path $Root 'scripts\validate_startup_items.ps1'
5+
$LogDir = Join-Path $Root 'logs'
6+
New-Item -ItemType Directory -Force -Path $LogDir | Out-Null
7+
$Report = Join-Path $LogDir ('startup_integrity_audit_{0}.md' -f (Get-Date -Format 'yyyy-MM-dd'))
8+
& $Validator -OutputPath $Report
9+
$Code = $LASTEXITCODE
10+
Copy-Item -LiteralPath $Report -Destination (Join-Path $LogDir 'startup_integrity_audit_latest.md') -Force
11+
exit $Code
Collapse file

‎scripts/start_feishu_agent.vbs‎

Copy file name to clipboard
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Set WshShell = CreateObject("WScript.Shell")
2+
WshShell.Run "powershell -WindowStyle Hidden -ExecutionPolicy Bypass -File ""D:\generic-agent\scripts\start_feishu_agent.ps1""", 0, False

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.