Skip to content

Commit 277f205

Browse files
committed
sentinel: Support hotpatching CRON
1 parent 342849a commit 277f205

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/sentinel/hotpatch.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { update as updatePSData } from 'ps-client/tools';
44

55
import { PSRoomConfigs } from '@/cache';
66
import { fetchRoomConfigs } from '@/database/psrooms';
7+
import PS from '@/ps';
78
import { registers } from '@/sentinel/registers';
89
import { cachebust, cachebustDir } from '@/utils/cachebust';
910
import { ChatError } from '@/utils/chatError';
@@ -26,11 +27,13 @@ export async function hotpatch(this: Sentinel, hotpatchType: HotpatchType, by: s
2627
$`git pull`;
2728
break;
2829
}
30+
2931
case 'data': {
3032
await updatePSData();
3133
// TODO: cachebust
3234
break;
3335
}
36+
3437
case 'roomconfigs':
3538
case 'room-configs': {
3639
const fetched = await fetchRoomConfigs();
@@ -40,6 +43,7 @@ export async function hotpatch(this: Sentinel, hotpatchType: HotpatchType, by: s
4043
});
4144
break;
4245
}
46+
4347
case 'sentinel': {
4448
cachebust('@/sentinel/create');
4549
cachebust('@/sentinel/hotpatch');
@@ -50,10 +54,20 @@ export async function hotpatch(this: Sentinel, hotpatchType: HotpatchType, by: s
5054
this.hotpatch = (await import('@/sentinel/hotpatch')).hotpatch;
5155
break;
5256
}
57+
58+
case 'cron':
59+
case 'schedule': {
60+
await cachebustDir(fsPath('@', 'ps', 'handlers', 'cron'));
61+
const { startPSCron } = await import('@/ps/handlers/cron');
62+
startPSCron.call(PS);
63+
break;
64+
}
65+
5366
case 'secrets': {
5467
await cachebustDir(fsPath('secrets'));
5568
break;
5669
}
70+
5771
default:
5872
const register = registers.list.find(register => register.label === hotpatchType);
5973
if (!register) throw new ChatError(`Hotpatch type ${hotpatchType} not found.` as NoTranslate);

0 commit comments

Comments
 (0)