|
1 | | -# Configuring a judge |
| 1 | +# Cấu hình Judge |
2 | 2 |
|
3 | | -The VNOJ judge is configured with a YAML file, which contains the runtimes, problems folders, and other information. |
| 3 | +Judge được cấu hình thông qua file YAML, chứa thông tin về ngôn ngữ lập trình, thư mục bài tập và các thiết lập khác. |
4 | 4 |
|
5 | | -A sample configuration file is available [here](https://github.com/VNOI-Admin/vnoj-docs/blob/master/sample_files/judge_conf.yml). |
| 5 | +File cấu hình mẫu: [judge_conf.yml](https://github.com/luyencode/docs/blob/master/sample_files/judge_conf.yml) |
6 | 6 |
|
7 | | -## Runtimes |
| 7 | +## Cấu trúc file cấu hình |
8 | 8 |
|
9 | | -The runtimes are configured with a `runtime` node. While most runtimes can be automatically configured with `dmoj-autoconf`, those that are not in the `$PATH` variable will not be automatically detected, and will need to be manually configured. |
| 9 | +### ID - Tên judge |
10 | 10 |
|
11 | | -## Problems |
| 11 | +Tên hiển thị của judge, phải trùng với tên đã tạo trên website: |
12 | 12 |
|
13 | | -The problems are configured with `problem_storage_globs`. This is a list of (potentially recursive) globs, as defined by Python's `glob` library. |
14 | | -Any folders that match any of the listed globs and contain an `init.yml` will be treated as a problem directory. |
15 | | -For example: |
16 | | -- `/mnt/problems/folder1/*` will match `/mnt/problems/folder1/problem1`. |
17 | | -- `/mnt/problems/folder2/**/` will match all subfolders of `/mnt/problems/folder2`, e.g. `/mnt/problems/folder2/foo/bar/problem2`. |
18 | | -- `/mnt/problems/folder3/year20[0-9][0-9]` will match `/mnt/problems/folder3/year2023`. |
| 13 | +```yaml |
| 14 | +id: judge1 |
| 15 | +``` |
19 | 16 |
|
20 | | -## ID |
| 17 | +### Key - Mã xác thực |
21 | 18 |
|
22 | | -The judge's display name is configured with an `id` node. This is a string, and it should match the one on the site interface. |
| 19 | +Mã bảo mật để judge kết nối với bridge, phải trùng với mã trên website: |
23 | 20 |
|
24 | | -## Key |
| 21 | +```yaml |
| 22 | +key: your_secret_key_here |
| 23 | +``` |
25 | 24 |
|
26 | | -This key is used to validate your judge's connection to the bridge, and as such, should match the one on the site interface. This is configured with a `key` node. |
| 25 | +### Problem Storage - Thư mục bài tập |
| 26 | +
|
| 27 | +Danh sách các thư mục chứa bài tập. Mỗi thư mục bài tập phải có file `init.yml`: |
| 28 | + |
| 29 | +```yaml |
| 30 | +problem_storage_globs: |
| 31 | + - /problems/* |
| 32 | + - /problems/archive/** |
| 33 | +``` |
| 34 | + |
| 35 | +**Ví dụ:** |
| 36 | +- `/problems/*` - Tìm tất cả thư mục con trực tiếp trong `/problems` |
| 37 | + - Khớp: `/problems/bai1`, `/problems/bai2` |
| 38 | + - Không khớp: `/problems/folder/bai3` |
| 39 | + |
| 40 | +- `/problems/archive/**` - Tìm tất cả thư mục con (bao gồm thư mục lồng nhau) |
| 41 | + - Khớp: `/problems/archive/2023/bai1`, `/problems/archive/bai2` |
| 42 | + |
| 43 | +- `/problems/year20[0-9][0-9]` - Tìm thư mục theo pattern |
| 44 | + - Khớp: `/problems/year2023`, `/problems/year2024` |
| 45 | + |
| 46 | +### Runtimes - Ngôn ngữ lập trình |
| 47 | + |
| 48 | +Cấu hình các ngôn ngữ lập trình được hỗ trợ: |
| 49 | + |
| 50 | +```yaml |
| 51 | +runtime: |
| 52 | + python3: /usr/bin/python3 |
| 53 | + gcc: /usr/bin/gcc |
| 54 | + g++: /usr/bin/g++ |
| 55 | +``` |
| 56 | + |
| 57 | +**Lưu ý:** |
| 58 | +- Hầu hết ngôn ngữ được tự động phát hiện bằng lệnh `dmoj-autoconf` |
| 59 | +- Chỉ cần cấu hình thủ công nếu chương trình không nằm trong `$PATH` |
| 60 | + |
| 61 | +## File cấu hình đầy đủ |
| 62 | + |
| 63 | +Ví dụ file `judge.yml` hoàn chỉnh: |
| 64 | + |
| 65 | +```yaml |
| 66 | +id: judge1 |
| 67 | +key: my_secret_authentication_key |
| 68 | +
|
| 69 | +problem_storage_globs: |
| 70 | + - /problems/* |
| 71 | +
|
| 72 | +runtime: |
| 73 | + python3: /usr/bin/python3 |
| 74 | + python2: /usr/bin/python2 |
| 75 | + gcc: /usr/bin/gcc |
| 76 | + g++: /usr/bin/g++ |
| 77 | + java: /usr/bin/java |
| 78 | +``` |
| 79 | + |
| 80 | +## Tự động phát hiện ngôn ngữ |
| 81 | + |
| 82 | +Để tự động phát hiện các ngôn ngữ có sẵn trên hệ thống: |
| 83 | + |
| 84 | +```sh |
| 85 | +dmoj-autoconf > judge.yml |
| 86 | +``` |
| 87 | + |
| 88 | +Sau đó chỉnh sửa file `judge.yml` để thêm `id`, `key` và `problem_storage_globs`. |
| 89 | + |
| 90 | +## Kiểm tra cấu hình |
| 91 | + |
| 92 | +Sau khi chỉnh sửa file cấu hình, khởi động lại judge: |
| 93 | + |
| 94 | +```sh |
| 95 | +docker restart judge |
| 96 | +``` |
| 97 | + |
| 98 | +Kiểm tra log để đảm bảo không có lỗi: |
| 99 | + |
| 100 | +```sh |
| 101 | +docker logs judge |
| 102 | +``` |
0 commit comments