|
2 | 2 | title: FAQ Collection |
3 | 3 | --- |
4 | 4 |
|
5 | | -## Quick Start and Community |
| 5 | +## Good news! This page and major browsers have partnered up—use Ctrl-F to quickly search keywords! |
6 | 6 |
|
7 | | -- **Tip**: Use `Ctrl+F` to quickly search for keywords on this page. |
8 | | -- **Community Support**: Join the Hydro User Group on QQ (1085853538). |
9 | | -- **In-depth Tutorials**: Explore [Common Tutorials](https://hydro.ac/d/faqs/p). |
10 | | -- **Feature Demo**: Visit [Hydro Demo Site](https://hydro.ac/discuss/6172ceeed850d38c79ae18f9) for a serverless experience. |
| 7 | +## For more tutorials, see [Common Tutorials](https://hydro.ac/d/faqs/p). |
11 | 8 |
|
12 | | -If you don't require heavy customization, we recommend using our online service. Our repository contains over 20,000 problems available for immediate use without any server maintenance. |
| 9 | +## User QQ Group: 1085853538 |
13 | 10 |
|
14 | | -### Frequently Asked Questions |
| 11 | +## How can I quickly get familiar with system features? |
15 | 12 |
|
16 | | -**Can I delete users?** |
17 | | -No. Users can only be edited or disabled. This design choice prevents accidental mass deletions ("teaching accidents"). |
| 13 | +Refer to this post: [https://hydro.ac/discuss/6172ceeed850d38c79ae18f9](https://hydro.ac/discuss/6172ceeed850d38c79ae18f9) for a serverless quick experience of system features. |
| 14 | +If you do not need heavy secondary development, we recommend using the online service directly. Problemsets with over 20,000 problems can be copied directly, with no need to buy cloud servers or maintain them manually. |
| 15 | +If you need customizations such as binding your own domain or changing logos, you can also enable advanced features in the admin panel yourself. |
18 | 16 |
|
19 | | -**What is an Online Judge (OJ)?** |
20 | | -An OJ is an automated system for evaluating programming solutions. It is not AI; it relies on strict input/output matching. |
21 | | -1. Teachers define problems with specific I/O formats. |
22 | | -2. Multiple sets of test data (input and expected output) are uploaded. |
23 | | -3. Students submit code. |
24 | | -4. The system runs the code and compares its output character-by-character with the expected output. |
25 | | -5. Exact matches pass; any difference (even an extra space or prompt like "Enter input:") results in a **Wrong Answer**. |
| 17 | +Users in the system only support edit and disable, not delete. This is to fundamentally prevent "teaching accidents." Please do not request user deletion features. If you are certain you will never misoperate, develop that feature yourself. |
| 18 | + |
| 19 | +## What is an OJ? |
| 20 | + |
| 21 | +The judging system you are using now is just a program, not artificial intelligence. So in many places, you need to adapt to it. Otherwise, even if your answer is essentially correct, format errors can make the system unable to understand it and still result in wrong answers. |
| 22 | +The system workflow is as follows: |
| 23 | + |
| 24 | +- Teachers add problems in the system and strictly define input/output formats. |
| 25 | +- Teachers add multiple sets of test data according to the problem format; each set includes input and expected output. |
| 26 | +- Students read the problem and submit programs based on their understanding. |
| 27 | +- The system compiles and runs student programs, then feeds the pre-provided input data to the programs and checks their output. |
| 28 | +- If a student's output is exactly identical to the teacher-provided output, character by character, the program is considered correct; otherwise it is considered wrong. |
| 29 | +- If memory/time limits are exceeded during execution, the program is interrupted and marked incorrect. |
| 30 | + |
| 31 | +After understanding the above, students should realize that if a problem does not require prompts like "Please Input Two Number", printing such text yourself will make your output differ from expected output, causing Wrong Answer. |
| 32 | +If a problem requires a blank line between every two output lines and you omit it, that is a format error, and vice versa. |
| 33 | +You may feel the system is bad for not auto-detecting this; in fact, this is exactly how it effectively trains programming precision and good coding habits. Many strong programmers started by complaining about this system and learned to code carefully and rigorously. |
| 34 | +To run all submissions in a unified way, the system must constrain submission format for everyone. |
| 35 | +For C/C++ learners, every submission must contain exactly one `main` function, it must return `int`, and preferably return 0, because non-zero return values are considered runtime errors by the operating system. |
| 36 | +When a compile error occurs, click the "Compile Error" text link for detailed explanation. |
| 37 | + |
| 38 | +## Error `[ERR_STREAM_PREMATURE_CLOSE]: Premature close` when installing in Arch Linux development mode |
26 | 39 |
|
27 | | -**Arch Linux: [ERR_STREAM_PREMATURE_CLOSE] during installation** |
28 | 40 | Delete `.yarnrc.yml` and `.yarn`, then try again. |
29 | 41 |
|
30 | | -**I can't access my site after installation.** |
31 | | -Ensure your cloud provider's **Security Group** allows inbound traffic on ports 80 and 443. |
| 42 | +## Why can't I access the site after installation? |
| 43 | + |
| 44 | +If you are using providers such as Alibaba Cloud/Tencent Cloud, ensure ports 80 and 443 are allowed in the security group. |
| 45 | + |
| 46 | +## Why can't I log in after configuring reverse proxy (caddy/nginx) (CsrfTokenError)? |
| 47 | + |
| 48 | +When reverse proxying, ensure the Host Header is set correctly. [Details](./install/proxy) |
| 49 | + |
| 50 | +## How to back up / restore backup / migrate data? |
| 51 | + |
| 52 | +`hydrooj backup` `hydrooj restore backup-xxx.zip` |
| 53 | + |
| 54 | +After learning how crontab works, you can use `sudo crontab -e` to create automatic backup schedules. |
| 55 | + |
| 56 | +## Upgrade |
| 57 | + |
| 58 | +See [Upgrade Guide](./FAQ/upgrade) |
32 | 59 |
|
33 | | -**CsrfTokenError / Login Issues** |
34 | | -Usually caused by incorrect reverse proxy headers (Caddy/Nginx). Ensure the `Host` header is set correctly. [See Details](./install/proxy). |
| 60 | +## How to import/create problems? |
35 | 61 |
|
36 | | -**Data Backup and Migration** |
37 | | -- **Backup**: `hydrooj backup` |
38 | | -- **Restore**: `hydrooj restore backup-filename.zip` |
39 | | -- Use `crontab` to automate this process (`sudo crontab -e`). |
| 62 | +There are corresponding entries on the right side of the problem list page. |
40 | 63 |
|
41 | | -**Should I import many problems at once?** |
42 | | -No. We recommend importing only the 5–10 problems needed for an assignment. This avoids clutter and maintains a logical progression for students. Focus on quality over quantity. |
| 64 | +Remember: do not import too many problems you do not need yet. The correct approach is to import only 5–10 required problems per training assignment. After the assignment/contest ends, let those become part of the training problemset. This keeps lower problem IDs gradually increasing in difficulty and makes self-training easier for later students. Do not chase quantity while ignoring quality. Use fewer problems you do not understand, and use them cautiously. |
43 | 65 |
|
44 | | -**Adding an ICP Filing Number** |
45 | | -In System Settings, add your link to the `footer_extra_html` field: |
46 | | -`<a href="https://beian.miit.gov.cn/">Your ICP Number Here</a>` |
| 66 | +## How to restrict access for unlogged users? |
47 | 67 |
|
48 | | -**What do "Time" and "Penalty" mean in contests?** |
49 | | -- **Spent Time**: `Time of successful submission - Contest start time + Penalty`. |
50 | | -- **Penalty**: Typically 20 minutes for each incorrect submission prior to acceptance. |
51 | | -- **OI Ranking**: Based on score (often proportional based on test cases passed). |
52 | | -- **Normal Ranking**: Based on the number of solved problems and spent time. |
| 68 | +Manage Domain -> Manage Permissions: disable the "View this domain" permission for Guest group. |
53 | 69 |
|
54 | | -**Where is Hydro installed?** |
55 | | -- Use `yarn global dir` to find the installation path. |
56 | | -- **Database**: `/data/db` (Use `hydrooj backup` instead of direct copying). |
57 | | -- **Files/Test Data**: `/data/file` |
58 | | -- **Configuration**: `/root/.config/hydro` and `/root/.hydro` |
| 70 | +## How to add ICP filing number in footer? |
59 | 71 |
|
60 | | -**What is the precision of time and memory limits?** |
61 | | -- **Time**: 1ms resolution (measured precision is ~4ms due to OS kernel). |
62 | | -- **Memory**: 1MB resolution. For interpreted languages (Python, Java), this includes the overhead of the VM/runtime. |
| 72 | +Add a line in system setting `footer_extra_html`: `<a href="https://beian.miit.gov.cn/">XX ICP XX No.</a>` |
63 | 73 |
|
64 | | -**"Outdated lockfile. Please run 'yarn install' and try again."** |
65 | | -Run: `cd $(yarn global dir) && rm -rf node_modules yarn.lock && yarn install` |
| 74 | +## What does time mean in contests/assignments? Difference between OI ranking and normal ranking? |
| 75 | +Time means the time "spent" for participants to solve a problem: |
| 76 | +That is: time solved – contest start time + penalty time |
| 77 | +Penalty time = number of wrong submissions before acceptance * 20 minutes. |
| 78 | +Normal ranking is based on number of solved problems and "spent" time. |
| 79 | +OI ranking is based on score. Problems can be scored proportionally by pass ratio, 100 points each. If you want non-uniform score distribution, use config. |
66 | 80 |
|
67 | | -**How can I add libraries like numpy to Python?** |
68 | | -For installations after 2022-08-12, please refer to the [Compiler section](./install/compiler). For older installations, run `pip3 install numpy` and `pm2 restart hydro-sandbox`. |
| 81 | +## Where does the script install OJ? |
| 82 | + |
| 83 | +You can get Hydro's default location with `yarn global dir`. (Do not modify code directly; updates will overwrite all changes there. Use the plugin API instead.) |
| 84 | +Default database files are in `/data/db`, but do not copy files directly; `hydrooj backup` is recommended. |
| 85 | +Files such as test data are stored in `/data/file`. |
| 86 | +Config files are in `/root/.config/hydro` and `/root/.hydro`. |
| 87 | +For production servers in operation, always make an offline backup before any operation. |
| 88 | +Always unzip backup files to verify all data is included, and check backup size (large systems should have backups of hundreds of MB). If possible, verify restore success in a VM. |
| 89 | + |
| 90 | +## What is the precision of time limit and memory limit? |
| 91 | + |
| 92 | +The literal time limit precision is 1ms, but due to OS kernel constraints, actual measured precision is usually 4ms. |
| 93 | +Memory limit precision is 1MB. For local native compiled languages like c/c++/pascal/freebasic/clang, it measures the program's own memory allocation; for VM/script languages, it includes memory consumed by the VM/interpreter itself. |
| 94 | + |
| 95 | +## `Outdated lockfile. Please run 'yarn install' and try again.` |
| 96 | + |
| 97 | +``` |
| 98 | +cd `yarn global dir` && rm -rf node_modules yarn.lock && yarn install |
| 99 | +``` |
| 100 | + |
| 101 | +Then try again. |
| 102 | + |
| 103 | +## I want Python to support numpy and similar libraries. What should I do? |
| 104 | + |
| 105 | +If installed before 2022/8/12, run `pip3 install numpy` then `pm2 restart hydro-sandbox` |
| 106 | +Otherwise refer to the [Compiler](./install/compiler) section. |
| 107 | + |
| 108 | +## I forgot MongoDB account/password after using installation script. What should I do? |
69 | 109 |
|
70 | | -**I forgot my MongoDB credentials.** |
71 | 110 | Check `/root/.hydro/config.json`. |
72 | 111 |
|
73 | | -**Disabling User Registration** |
74 | | -Registration is controlled via the Guest group's permissions (UID 0). |
75 | | -- **Disable**: `hydrooj cli user setPriv 0 0` |
76 | | -- **Enable**: `hydrooj cli user setPriv 0 8` |
77 | | -After making changes, restart the service: `pm2 restart hydrooj`. |
| 112 | +## How to disable/enable user registration? |
| 113 | + |
| 114 | +Registration is controlled by Guest user (uid = 0) permission PRIV_REGISTER_USER, enabled by default. |
| 115 | +Use `hydrooj cli user setPriv 0 0` to disable registration. |
| 116 | +To re-enable, use `hydrooj cli user setPriv 0 8`. |
| 117 | + |
| 118 | +After changing it, restart hydrooj service: `pm2 restart hydrooj` |
78 | 119 |
|
79 | | -**What is the "Hydro" system user (UID 1)?** |
80 | | -This account is used solely for sending system notifications and cannot be logged into. |
| 120 | +## What is user Hydro for? What's the password? Can it log in? |
81 | 121 |
|
82 | | -**Changing the Website Icon/Logo** |
83 | | -1. Use `hydrooj addon create` to generate a plugin. |
84 | | -2. Place your icons in `/root/addon/public/` (e.g., `favicon.ico`, `nav_logo_dark.png`). |
85 | | -3. Update the `nav_logo_dark` path in System Settings to `/nav_logo_dark.png`. |
| 122 | +User Hydro (uid = 1) is only for sending system messages (similar to 10000 in QQ) and cannot log in. |
| 123 | + |
| 124 | +## How to modify website icon? |
| 125 | + |
| 126 | +Use `hydrooj addon create` to create a plugin, which will create `/root/addon` automatically. |
| 127 | +Go to `/root/addon/public`, and place your site icons there. |
| 128 | +You need these files in that directory (for different browsers): |
| 129 | + |
| 130 | +- `favicon-16x16.png` |
| 131 | +- `favicon-32x32.png` |
| 132 | +- `favicon-96x96.png` |
| 133 | +- `favicon.ico` (32x32) |
| 134 | +- `android-chrome-192x192.png` |
| 135 | +- `apple-touch-icon-180x180.png` |
| 136 | + |
| 137 | +Matching resolution is recommended but not mandatory. These images are shown on browser tabs. |
| 138 | +You also need this file in that directory: |
| 139 | + |
| 140 | +- `nav_logo_dark.png` |
| 141 | + |
| 142 | +This image is shown as the top-left logo. |
| 143 | +Then go to system settings, find `nav_logo_dark`, change it to `/nav_logo_dark.png`, and restart Hydro to apply changes. |
| 144 | + |
| 145 | +Remember to clear browser cache. |
| 146 | + |
| 147 | +## How to reset data? |
86 | 148 |
|
87 | | -**How do I reset all data?** |
88 | 149 | <Callout type="warn"> |
89 | | -This will permanently delete all users, problems, and contests. |
| 150 | +This operation will delete all users/problems/contests and other data. Proceed with caution! |
90 | 151 | </Callout> |
91 | | -Download and run the [reset script](https://github.com/hydro-dev/Hydro/blob/master/install/reset.sh). |
92 | 152 |
|
93 | | -**Judge error: "Total time limit exceeds 60s"** |
94 | | -Increase the `total_time_limit` in System Settings. |
| 153 | +Download [this script](https://github.com/hydro-dev/Hydro/blob/master/install/reset.sh) and run it on the server. |
| 154 | + |
| 155 | +You can adjust as needed; display order matches the order in configuration. |
| 156 | + |
| 157 | +## Judge shows "Total time limit exceeds 60s, judging canceled" |
| 158 | + |
| 159 | +In system settings, modify `total_time_limit` to the allowed maximum judging duration per problem. |
| 160 | + |
| 161 | +## How to add line animation effects in background? |
| 162 | + |
| 163 | +After creating a plugin, put the following content in plugin `frontend/animation.page.ts`: |
| 164 | + |
| 165 | +> Based on https://github.com/hustcc/canvas-nest.js , MIT |
95 | 166 |
|
96 | | -**Adding background animation effects** |
97 | | -Create a plugin and add the following to `frontend/animation.page.ts`: |
98 | 167 | ```js |
99 | | -// Based on https://github.com/hustcc/canvas-nest.js (MIT) |
100 | 168 | (()=>{function e(e,n,t){return e.getAttribute(n)||t}function n(){l=i.width=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,u=i.height=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight}function c(){var t,o,i,a,m;r.clearRect(0,0,l,u),s.forEach(function(e,n){for(e.x+=e.xa,e.y+=e.ya,e.xa*=e.x>l||e.x<0?-1:1,e.ya*=e.y>u||e.y<0?-1:1,r.fillRect(e.x-.5,e.y-.5,1,1),o=n+1;o<d.length;o++)null!==(t=d[o]).x&&null!==t.y&&(i=e.x-t.x,a=e.y-t.y,(m=i*i+a*a)<t.max&&(t===y&&m>=t.max/2&&(e.x-=.03*i,e.y-=.03*a),m=(t.max-m)/t.max,r.beginPath(),r.lineWidth=m/2,r.strokeStyle="rgba("+x.c+","+(.2+m)+")",r.moveTo(e.x,e.y),r.lineTo(t.x,t.y),r.stroke()))}),w(c)}var l,u,d,t,o,i=document.createElement("canvas"),x=(t=(o=document.getElementsByTagName("script")).length,o=o[t-1],{l:t,z:e(o,"zIndex",-1),o:e(o,"opacity",.5),c:e(o,"color","0,0,0"),n:e(o,"count",99)}),a="c_n"+x.l,r=i.getContext("2d"),w=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(e){window.setTimeout(e,1e3/45)},m=Math.random,y={x:null,y:null,max:2e4};i.id=a,i.style.cssText="position:fixed;top:0;left:0;z-index:"+x.z+";opacity:"+x.o,document.getElementsByClassName("main")[0].appendChild(i),n(),window.onresize=n,window.onmousemove=function(e){e=e||window.event,y.x=e.clientX,y.y=e.clientY},window.onmouseout=function(){y.x=null,y.y=null};for(var s=[],h=0;x.n>h;h++){var f=m()*l,g=m()*u,p=2*m()-1,v=2*m()-1;s.push({x:f,y:g,xa:p,ya:v,max:6e3})}d=s.concat([y]),setTimeout(function(){c()},100)})(); |
101 | 169 | ``` |
102 | 170 |
|
103 | | -**How much does Hydro cost?** |
104 | | -Hydro is free and open-source under the AGPL license. You can support the developer via [donations](https://pay.undefined.moe). |
| 171 | +## How much does Hydro cost? |
| 172 | + |
| 173 | +It's free. We are AGPL. If you have extra money, you can [send me a red packet](https://pay.undefined.moe). |
| 174 | + |
| 175 | +## execve: no such file or directory |
| 176 | + |
| 177 | +Script installation installs only a small subset of compilers by default. Please refer to the [Compiler](./install/compiler) section to install/configure other compilers. |
105 | 178 |
|
106 | | -**"execve: no such file or directory"** |
107 | | -The installation script sets up core compilers only. Refer to the [Compiler section](./install/compiler) for additional runtimes. |
| 179 | +## How to customize user badges? |
| 180 | + |
| 181 | +Enter MongoDB and execute the following (replace placeholders in angle brackets accordingly): |
108 | 182 |
|
109 | | -**How do I customize user badges?** |
110 | | -In MongoDB: |
111 | 183 | ```sh |
112 | 184 | use hydro |
113 | | -db.user.update({"_id": <USER_UID>}, {$set: {"badge": "<Label>#<Background_HEX>#<Text_HEX>"}}) |
| 185 | +db.user.update({"_id": <USER UID>}, {$set: {"badge": "<Label>#<Background HEX>#<Text HEX>"}}) |
114 | 186 | ``` |
115 | 187 |
|
116 | | -**Why can't I batch download files?** |
117 | | -Ensure your site is using HTTPS and that you are using a modern browser. Otherwise, use `Ctrl+Click` to download files individually. |
| 188 | +## Why can't I batch download multiple files? |
| 189 | + |
| 190 | +Please use a modern browser and try enabling HTTPS for your site. |
| 191 | +Otherwise, download files one by one (Ctrl+click filename). |
| 192 | + |
| 193 | +## Why is there no language option on my submission page? |
118 | 194 |
|
119 | | -**Why are there no language options on the submission page?** |
120 | | -Check **Problem -> Judge Settings** and **Domain Settings -> Edit Domain Profile**. Ensure "Allowed languages" contains comma-separated language IDs (e.g., `c,cc,py3`). Leave empty for defaults. |
| 195 | +Problem -> Judge Settings -> Allowed languages |
| 196 | +Domain Settings -> Edit Domain Profile -> Allowed languages |
| 197 | +In both places, fill language IDs separated by English commas. If unsure, leave empty. |
121 | 198 |
|
122 | | -**"The 'yarn global' commands have been removed in 2.x"** |
123 | | -This affects development mode. We recommend using the installation script unless you are specifically working on Hydro development. |
| 199 | +## The 'yarn global' commands have been remove in 2.x - consider using 'yarn dlx' or a third-party plugin instead |
124 | 200 |
|
125 | | -**Rate Limiting Issues** |
126 | | -If many users share an IP (e.g., in a lab): |
127 | | -- Set up a proxy server to forward individual IPs (Recommended). |
128 | | -- Increase limits: `hydrooj cli system set limit.user_login 999`. |
129 | | -- Start with `--benchmark` to disable rate limiting (Not recommended). |
| 201 | +If you cannot understand this issue, just use the installation script and do not mess with development mode. |
130 | 202 |
|
131 | | -**Memory/Disk usage on Judge** |
132 | | -Hydro uses `/dev/shm` for temporary judge files. Ensure it has at least 512MB: |
133 | | -- View size: `df -h /dev/shm` |
134 | | -- Increase size: `sudo mount -o remount,size=1G /dev/shm` |
| 203 | +## I'm in a computer lab environment; many users share one IP and trigger rate limits. How to solve? |
| 204 | + |
| 205 | +Option 1: Set up a proxy server in the intranet and forward intranet IPs to the server. (Recommended) |
| 206 | +Option 2: Use commands like `hydrooj cli system set limit.user_login 999` to set new rate limits (the error page shows which limit was triggered) |
| 207 | +Option 3: Start with `pm2 start hydrooj -- --benchmark` to disable all rate limits (Not recommended) |
| 208 | + |
| 209 | +## Adjust temporary directory size |
| 210 | + |
| 211 | +Judge stores temporary files in /dev/shm, including contestants' output, compiled executables, etc. These files are automatically deleted after judging. |
| 212 | +If you set high parallel judging, pay attention to /dev/shm size limit. We usually recommend reserving at least 512MB. |
| 213 | + |
| 214 | +Check /dev/shm size: |
| 215 | + |
| 216 | +```bash |
| 217 | +df -h /dev/shm |
| 218 | +``` |
135 | 219 |
|
| 220 | +Adjust /dev/shm size: |
136 | 221 |
|
| 222 | +```bash |
| 223 | +sudo mount -o remount,size=1024M /dev/shm |
| 224 | +``` |
0 commit comments