이벤트 모니터링
Session Lifecycle Events
URI:
/events/session
메소드 :
GET
Provides a continuous message-by-message JSON object stream of session lifecycles. It uses HTML5 Server-Sent Events (SSE). Browser-based clients may use the EventSource API for convenience.
Added in version v4.20190615: 이 버전에서 처음 적절하게 구현되었고 구현 되지 않았던 이전 인터페이스는 폐지됩니다.
버전 v5.20191215에서 변경: The URI is changed from /stream/session/_/events
to /events/session
.
매개변수들
매개변수 |
타입 |
설명 |
---|---|---|
|
|
The session ID to monitor the lifecycle events.
If set |
|
|
(선택사항) 다른 액세스 키(사용자)가 다른 세션 인스턴스에 대해 동일한 세션 아이디를 공유할 수 있기 때문에 지정된 세션 소유자의 접근 키 입니다. 도메인 소유자나 슈퍼관리자만이 이를 지정할 수 있습니다. |
|
|
The group name to filter the lifecycle events.
If set |
응답
응답은 text/event-stream
형식을 따르는 연속적인 여러 줄의 UTF-8 텍스트 스트림입니다. 각 이벤트는 이벤트 타입과 데이터로 구성되어 있으며, 데이터는 JSON 으로 인코딩 됩니다.
가능한 이벤트 명(추후 더 많은 이벤트가 추가될 수 있습니다)
이벤트 명 |
설명 |
---|---|
|
세션이 방금 작업 큐에 스케쥴링 되었고, 에이전트로부터 자원 할당을 받았습니다. |
|
The session begins pulling the session image (usually from a Docker registry) to the scheduled agent. |
|
세션이 컨테이너 (또는 다른 에이전트 백엔드의 다른 객체로) 생성되는 중입니다. |
|
세션에서 코드를 실행할 준비를 마쳤습니다. |
|
세션이 종료되었습니다. |
이벤트소스 API를 사용할 경우, 다음을 따르는 이벤트 리스너를 추가해주십시오 :
const sse = new EventSource('/events/session', {
withCredentials: true,
});
sse.addEventListener('session_started', (e) => {
console.log('session_started', JSON.parse(e.data));
});
참고
이벤트소스 API는 (콘솔-서버가 종단점 일 때) 반드시 브라우저 쿠키를 사용하는 세션-기반 인증 모드여야 합니다. 다른 방식으로는 관리자 서버에 대해 실행되는 표준 fetch API를 사용해 이벤트 스트림 파서를 수동으로 구현해야 합니다.
이벤트 데이터는 다음과 같은 JSON 문자열로 구성됩니다 (추후 더 많은 필드가 추가될 수 있음) :
필드 명 |
설명 |
---|---|
|
소스 세션 아이디 |
|
세션을 소유하고 있는 액세스 키 |
|
이 이벤트가 왜 발생했는지에 대한 짧은 문자열입니다. 이것은 ``null``이거나 빈 문자열일 수 있습니다. |
|
Only present for |
{
"sessionId": "mysession-01",
"ownerAccessKey": "MYACCESSKEY",
"reason": "self-terminated",
"result": "SUCCESS"
}
Background Task Progress Events
URI:
/events/background-task
Method:
GET
for server-side events
Added in version v5.20191215.
매개변수들
매개변수 |
타입 |
설명 |
---|---|---|
|
|
The background task ID to monitor the progress and completion. |
응답
The response is a continuous stream of UTF-8 text lines following text/event-stream
format.
Each event is composed of the event type and data, where the data part is encoded as JSON.
Possible event names (more events may be added in the future):
이벤트 명 |
설명 |
---|---|
|
Updates for the progress. This can be generated many times during the background task execution. |
|
The background task is successfully completed. |
|
The background task has failed.
Check the |
|
The background task is cancelled in the middle. Usually this means that the server is being shutdown for maintenance. |
|
This event indicates explicit server-initiated close of the event monitoring connection, which is raised just after the background task is either done/failed/cancelled. The client should not reconnect because there is nothing more to monitor about the given task. |
The event data (per-line JSON objects) include the following fields:
필드 명 |
타입 |
설명 |
---|---|---|
|
|
The background task ID. |
|
|
The current progress value.
Only meaningful for |
|
|
The total progress count.
Only meaningful for |
|
|
An optional human-readable message indicating what the task is doing.
It may be |
Check out the session lifecycle events API for example client-side Javascript implementations to handle text/event-stream
responses.
If you make the request for the tasks already finished, it may return either “404 Not Found” (the result is expired or the task ID is invalid) or a single event which is one of task_done
, task_fail
, or task_cancel
followed by immediate response disconnection.
Currently, the results for finished tasks may be archived up to one day (24 hours).