Warning
This tool can be used with folkiesss/cafe-grader-docker, but you will need to modify how directories are called by importing the tool into the container. This is because the program still relies on certain OS file operations.
cafegrader-manager was created to help configure the Cafe Grader system together with a Cronjob-style scheduler (crontab), enabling automatic scheduled opening/closing of the system (Admin/Single Mode), deletion of Judge Log files, and enabling/disabling of Contest Mode at specified times.
- Enable/disable Admin/Single Mode
- Used to lock the website so that only Administrators can log in.
- Delete data in the Judge folder
(~/cafe_grader/judge/isolate_submission)safely, even over short intervals, compared to the old system. This is well suited for servers with limited hard disk space.- With the old system, configuring deletion to run at short intervals (under 30 minutes) could cause problems where the Worker is unable to check program results, resulting in a
[!]or[x]verdict. - This program can be scheduled to delete files at a per-minute interval and can safely be used during an ongoing exam, because before the system deletes the file/folder for a given Submission ID, it always checks whether that submission is still being processed by a Worker.
- If a given Submission ID is still being processed by a Worker, it will be skipped and re-checked later.
- With the old system, configuring deletion to run at short intervals (under 30 minutes) could cause problems where the Worker is unable to check program results, resulting in a
- Enable/disable Contest Mode
- The CLI program currently does not support creating, editing, or deleting Contests themselves. It can only enable Contest Mode globally from the system's settings menu.
Database:
- MySQL or MariaDB
Judge Machine/Instances:
- crontab
- cat
- git
- curl
- Text Editor (nano/vim) -- optional
- GoLang (if you want to compile the binary yourself)
There are two main installation methods: running the automated script setup-cronjob.sh, or Manual Setup. Steps for each are as follows.
- Download the executable from the Releases section of this repository and move it to the directory where you want to store it.
- Navigate to the directory where you stored the executable, then run the following command:
curl https://raw.githubusercontent.com/cedt-mock-exam/cafegrader-manager/refs/heads/main/setup-cronjob.sh | bash- Enter the Database credentials (Username, Password, Host, Port, Database Name) and the Judge Directory when prompted by the system.
- Once entered successfully, the system will automatically set up a script to clean Judge Logs every 3 hours (you can change this later yourself using the
crontab -ecommand; look for the line referencingcafegrader-manager clean_judge).
Note: If the system reports back no crontab for XXXX, you can ignore this message, as it simply indicates that no cronjob has previously been created on the system.
- Install GoLang in order to compile the binary.
- You can use a version manager tool (such as asdf) as long as you can run the
go versioncommand.
- You can use a version manager tool (such as asdf) as long as you can run the
- Clone the repository from GitHub using the
mainbranch. - Run the command
go build -o cafegrader-manager main.go. - Use the
crontabprogram to configure the schedule for running the program at the desired times.- This is typically done using the
crontab -ecommand.
- This is typically done using the
- Add a cronjob entry in the following format:
# This is an example for run every hours.
0 * * * * /path/to/cafegrader-manager -u <DB_USER> -p <DB_PASS> -H <DB_HOST> -P <DB_PORT> -d <DB_NAME> -r <CAFE_JUDGE_PATH> [COMMANDS] [ARGS]
# Example for clean judge (Every 3 hours)
0 */3 * * * /home/cafe/cafegrader-manager -u root -p cafe_password -H 127.0.0.1 -P 3306 -d grader -r /var/www/cafe_grader/judge clean_judge
# Example for enable admin mode (Every 02:00AM)
0 2 * * * /home/cafe/cafegrader-manager -u root -p cafe_password -H 127.0.0.1 -P 3306 -d grader admin_mode --admin=true- Once the cronjob has been configured successfully, exit the editor. Crontab will then save the configuration and begin running it at the specified times immediately.
This program is a CLI (Command Line Interface) tool. You can invoke it using commands in the following format:
# In case use default arguments
cafegrader-manager [FLAGS] [COMMANDS] [ARGS]
cafegrader-manager -p <DB_PASS> admin_mode --admin=<true | false>
cafegrader-manager -p <DB_PASS> clean_judge
# In case use another arguments
cafegrader-manager -u <DB_USER> -p <DB_PASS> -H <DB_HOST> -P <DB_PORT> -d <DB_NAME> admin_mode --admin=<true | false>
cafegrader-manager -u <DB_USER> -p <DB_PASS> -H <DB_HOST> -P <DB_PORT> -d <DB_NAME> -r <CAFE_JUDGE_PATH> clean_judgeFor more detailed usage instructions, run cafegrader-manager --help.