In this issue, we recommend Hcode Online Judge, an online evaluation platform based on SpringCloud and Vue that separates the front-end and back-end.
Hcode Online Judge (HOJ): Based on the separation of front-end and back-end, online evaluation platform (hoj) with distributed architecture, the front-end uses vue, the back-end mainly uses springboot, redis, mysql, nacos and other technologies, supports HDU, POJ, Codeforces (including GYM) vjudge judgment, and adapts to mobile phone and computer browsing, has a discussion area and an on-site message system, supports private training, Open training (question list), as well as perfect question judgment mode (ordinary assessment, special assessment, interactive evaluation) and perfect competition functions (star team, follow team, external list).
characteristic
Distributed: Supports the flexible increase or decrease of multiple judgment services
Efficient: Front-end and back-end separation is adopted, rapid development is adopted, and high-performance reusable question judgment sandbox is used
Customization: The website is highly centralized and supports customized modification
Security: The problem is judged by using cgroup to isolate user programs, and the website permission control is perfect
Diversification: Exclusive self-judgment service, and support the submission of other well-known OJ questions
Screenshot of the page
The following screenshot pages all support Chinese and English internationalization, click Convert at the bottom to convert the whole website, including background management, and the browser will remember the language selected this time.
Home page
- The first page is in English
- On-site messaging system
- Question list page
- Question details page
- Training list page
- Training question list page
- Tournament list page
- Tournament leaderboards
Rapid deployment
Environment preparation: docker and docker-compose
1. Stand-alone deployment
1. Select the location where you want to install it and run the following command:
git clone https://gitee.com/himitzh0730/hoj-deploy.git && cd hoj-deploy
2. Go to the folder and use docker-compose to start each container service:
cd standAlone
The standAlone folder file has the following:
├── docker-compose.yml
├── .env
For the main configuration, please modify the .env file, which is as follows:
Note: It is best not to change the IP address of each service and keep it on the Docker network in the 172.20.0.0/16 network segment
# Folder location of all hoj data storage (the current path generates hoj folder by default)
HOJ_DATA_DIRECTORY=./hoj
# Redis configuration
REDIS_HOST=172.20.0.2
REDIS_PORT=6379
REDIS_PASSWORD=hoj123456
# MySQL configuration
MYSQL_HOST=172.20.0.3
# If the judgment service is distributed, please provide the public IP address of the server where MySQL is located
MYSQL_PUBLIC_HOST=172.20.0.3
MYSQL_PORT=3306
MYSQL_ROOT_PASSWORD=hoj123456
# Configuration of NACOS
NACOS_HOST=172.20.0.4
NACOS_PORT=8848
NACOS_USERNAME=root
NACOS_PASSWORD=hoj123456
# Configure the backend service
BACKEND_HOST=172.20.0.5
BACKEND_PORT=6688
# Token encryption key The default is to generate a 32-bit random key
JWT_TOKEN_SECRET=default
# The token expiration time is 86400s in 24 hours by default
JWT_TOKEN_EXPIRE=86400
# The token can be automatically refreshed every 12 hours by default
JWT_TOKEN_FRESH_EXPIRE=43200
# The token that calls the judgment server will generate a 32-bit random key by default
JUDGE_TOKEN=default
# Please use the domain name or IP address of the mail service
EMAIL_SERVER_HOST=smtp.qq.com
EMAIL_SERVER_PORT=465
EMAIL_USERNAME=your_email_username
EMAIL_PASSWORD=your_email_password
# To enable virtual judgment, please provide the account and password corresponding to OJ in the format of
# username1,username2,…
# password1,password2,…
HDU_ACCOUNT_USERNAME_LIST=
HDU_ACCOUNT_PASSWORD_LIST=
CF_ACCOUNT_USERNAME_LIST=
CF_ACCOUNT_PASSWORD_LIST=
POJ_ACCOUNT_USERNAME_LIST=
POJ_ACCOUNT_PASSWORD_LIST=
# JudgeServer configuration
JUDGE_SERVER_IP=172.20.0.7
JUDGE_SERVER_PORT=8088
JUDGE_SERVER_NAME=judger-alone
# -1 indicates that the maximum number of tasks that can be accepted is the number of CPU cores + 1
MAX_TASK_NUM=-1
# Whether the remote virtual question judgment function is enabled on the current question judgment server
REMOTE_JUDGE_OPEN=true
# -1 indicates that the maximum number of remote judgment tasks that can be received is the number of CPU cores × 2+1
REMOTE_JUDGE_MAX_TASK_NUM=-1
# The default number of sandbox parallel judgment programs is the number of CPU cores
PARALLEL_TASK=default
# Docker Network configuration
SUBNET=172.20.0.0/16
Tip: If the memory of the server is 4G or above, please remove the JVM limit to greatly increase the concurrency, and perform the following steps:
vim docker-compose.yml
Comment or omit the selected row from the diagram:
(1) hoj-back module
② hoj-judgeservermodule
If it is not changed, it will be started with the default parameters (the test can not be changed, but please modify the password of the default configuration for official deployment!) )
docker-compose up -d
Depending on the network speed, it takes about 10 to 20 minutes to pull the image without manual intervention, and after the pull is completed, the container service will be automatically started, which will take about 1 to 2 minutes to initialize.
After the command is executed, check the container status:
docker ps -a
When you see that the status of all containers is UP or healthy, it means that OJ has been successfully started.
The following default parameters are described:
Default super administrator account and password: root / hoj123456
Default Redis password: hoj123456 (please modify for official deployment)
Default MySQL account and password: root/hoj123456 (please modify for official deployment)
Default NACOS administrator account and password: root/hoj123456 (please modify for official deployment)
HTTPS is not enabled by default, and the file to be modified is enabled and the certificate file is provided
By default, the number of concurrent CPUs is +1
VJ judgment is enabled by default, you need to manually modify and add the account and password, if you don’t add it, you can’t VJ judgment!
The default number of concurrent VJ judgments is the number of CPU cores x 2+1
Log in to the root account to check the service status in the background and modify the service configuration in http://ip/admin/conf!
Note: The email system is required for website registration and user account related operations, so please configure your own SMTP email service in the system configuration.
If you have already configured the mail service in the .env file at startup, you do not need to modify it again.
Host: smtp.qq.com
Port: 465
Username: qq email account
Password: A random authorization code generated after the SMTP service is enabled
2. Distributed deployment
For the firewall of the primary server (running nacos, backend, frontend, and redis), please open port number 8848, 3306, and 873
From the server firewall of the server (running judgeserver), open port 8088
1. Select the location where you want to install it and run the following command:
git clone https://gitee.com/himitzh0730/hoj-deploy.git && cd hoj-deploy
2. Go to the folder:
cd distributed
The distributed folder has the following:
├── judgeserver
├── main
3. Deploy the main service, which is DataBackup.
cd main
The folder has:
├── docker-compose.yml
├── .env
Modify the configuration in the .env file
vim .env
Note: It is best not to change the IP address of each service and keep it on the Docker network in the 172.20.0.0/16 network segment
# Folder location of all hoj data storage (the current path generates hoj folder by default)
HOJ_DATA_DIRECTORY=./hoj
# Redis configuration
REDIS_HOST=172.20.0.2
REDIS_PORT=6379
REDIS_PASSWORD=hoj123456
# MySQL configuration
MYSQL_HOST=172.20.0.3
# Please provide the public IP address of the server where MySQL resides
MYSQL_PUBLIC_HOST=172.20.0.3
MYSQL_PORT=3306
MYSQL_ROOT_PASSWORD=hoj123456
# Configuration of NACOS
NACOS_HOST=172.20.0.4
NACOS_PORT=8848
NACOS_USERNAME=root
NACOS_PASSWORD=hoj123456
# Configure the backend service
BACKEND_HOST=172.20.0.5
BACKEND_PORT=6688
# Token encryption key The default is to generate a 32-bit random key
JWT_TOKEN_SECRET=default
# The token expiration time is 86400s in 24 hours by default
JWT_TOKEN_EXPIRE=86400
# The token can be automatically refreshed every 12 hours by default
JWT_TOKEN_FRESH_EXPIRE=43200
# The token that calls the judgment server will generate a 32-bit random key by default
JUDGE_TOKEN=default
# Please use the domain name or IP address of the mail service
EMAIL_SERVER_HOST=smtp.qq.com
EMAIL_SERVER_PORT=465
EMAIL_USERNAME=your_email_username
EMAIL_PASSWORD=your_email_password
# To enable virtual judgment, please provide the account and password corresponding to OJ in the format of
# username1,username2,…
# password1,password2,…
HDU_ACCOUNT_USERNAME_LIST=username1,username2
HDU_ACCOUNT_PASSWORD_LIST=password1,password2
CF_ACCOUNT_USERNAME_LIST=
CF_ACCOUNT_PASSWORD_LIST=
POJ_ACCOUNT_USERNAME_LIST=
POJ_ACCOUNT_PASSWORD_LIST=
# Evaluate the configuration of data synchronization
# Please change the data synchronization password
RSYNC_PASSWORD=hoj123456
# Docker Network configuration
SUBNET=172.20.0.0/16
After the configuration modifications are saved, the service is started in the current path
docker-compose up -d
Depending on the internet speed, it can be installed in about 10 minutes, without human intervention.
After the command is executed, check the container status
docker ps -a
When you see that the status of all containers is UP or healthy, it means that OJ has been successfully started.
4. Then, on another server, still git clone the folder, then go to the judgeserver folder and modify the configuration of the .env
# Folder location of all hoj data storage (default current path generates judge folder)
HOJ_JUDGESERVER_DATA_DIRECTORY=./judge
# Configuration of NACOS
# Changed to the IP address of the service where Nacos resides
NACOS_HOST=NACOS_HOST
# Changed to Nacos startup port number, which is 8848 by default
NACOS_PORT=8848
# Changed to the administrator account of Nacos
NACOS_USERNAME=root
# Change the administrator password of Nacos
NACOS_PASSWORD=hoj123456
# JudgeServer configuration
#修改服务器公网ip
JUDGE_SERVER_IP=172.20.0.7
JUDGE_SERVER_PORT=8088
JUDGE_SERVER_NAME=judger-1
# -1 indicates that the maximum number of tasks that can be accepted is the number of CPU cores + 1
MAX_TASK_NUM=-1
# Whether the remote virtual question judgment function is enabled on the current question judgment server
REMOTE_JUDGE_OPEN=true
# -1 indicates that the maximum number of remote judgment tasks that can be received is the number of CPU cores × 2+1
REMOTE_JUDGE_MAX_TASK_NUM=-1
# The default number of sandbox parallel judgment programs is the number of CPU cores
PARALLEL_TASK=default
# rsync evaluates the configuration of data synchronization
# Write to the IP address of the primary server
RSYNC_MASTER_ADDR=127.0.0.1
# The rsync password is the same as that of the primary server
RSYNC_PASSWORD=hoj123456
After the configuration modifications are saved, the service is started in the current path
docker-compose up -d
Tip: You need to turn on multiple machines, just like the operation in step 4 at the moment, and perform the above operations on each server.
5. After both services are started, enter the main service IP or domain name in the browser to access, log in to the root account to check the service status in the background.
This project uses the MIT open source license, and you can read more about it by yourself.