문서 수정: 턴 다이아몬드 생명주기 문서에 API 요청 처리 및 일시 정지/재개 기능 추가
This commit is contained in:
@@ -36,12 +36,29 @@ Idle -> Running -> Flushing -> Idle
|
|||||||
|
|
||||||
## Main Loop Sketch
|
## Main Loop Sketch
|
||||||
|
|
||||||
|
The daemon interleaves API request handling between scheduled turn executions.
|
||||||
|
API requests are drained until the next turn time is reached; once the turn
|
||||||
|
starts, incoming requests are queued and processed after the run.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
while (!stopping) {
|
while (!stopping) {
|
||||||
await waitForNextTrigger(nextTurnTime, wakeSignal);
|
const signal = await waitForNextSignal(nextTurnTime, wakeSignal);
|
||||||
|
if (signal.type === 'pause') {
|
||||||
|
paused = true;
|
||||||
|
}
|
||||||
|
if (signal.type === 'resume') {
|
||||||
|
paused = false;
|
||||||
|
}
|
||||||
if (paused || running) {
|
if (paused || running) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await drainApiRequestsUntil(nextTurnTime);
|
||||||
|
|
||||||
|
if (now() < nextTurnTime && signal.type !== 'run') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
running = true;
|
running = true;
|
||||||
try {
|
try {
|
||||||
await runUntil(now(), budget);
|
await runUntil(now(), budget);
|
||||||
@@ -53,6 +70,10 @@ while (!stopping) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
- `drainApiRequestsUntil()` processes queued user/admin requests and applies
|
||||||
|
them to in-memory state until the next scheduled turn time is reached.
|
||||||
|
- During `running`, new API requests are enqueued and handled after the run.
|
||||||
|
|
||||||
## Run Budget and Checkpoints
|
## Run Budget and Checkpoints
|
||||||
|
|
||||||
Replace PHP `max_execution_time` with explicit limits to allow partial progress:
|
Replace PHP `max_execution_time` with explicit limits to allow partial progress:
|
||||||
|
|||||||
Reference in New Issue
Block a user