ojudge

A competitive programming judging platform written in OCaml
git clone git://git.laack.co/ojudge.git
Log | Files | Refs | README

commit 9a4358f663fdd156f0ebd9e102e35e8e4166bfb4
parent caf560fb60d1b05c58bc045a937ca42ccf1baa0b
Author: Andrew Laack <andrew@laack.co>
Date:   Fri, 13 Nov 2026 14:31:03 -0600

Basic deployment scripting

Diffstat:
MMakefile | 15+++++++++++++++
MREADME | 24++++++++++++++++++++++++
Acgi-bin/example.sh | 4++++
Acgi-bin/home.sh | 2++
Alighttpd.conf | 27+++++++++++++++++++++++++++
Ascripts/example.sh | 4++++
Ascripts/home.sh | 2++
7 files changed, 78 insertions(+), 0 deletions(-)

diff --git a/Makefile b/Makefile @@ -4,3 +4,18 @@ build-container: run-container: cd example && \ timeout 5 podman run --rm -v ./code:/code:ro -v ./inputs:/inputs:ro -v ./outputs:/outputs:rw --network=none --memory=256MB --cpus 1 judge + +build-cgi: + mkdir -p cgi-bin + cp scripts/example.sh cgi-bin/example.sh + cp scripts/home.sh cgi-bin/home.sh + +deploy-server: build-cgi + sudo rm -rf /srv/http/cgi-bin + sudo cp -r cgi-bin /srv/http/ + sudo cp lighttpd.conf /etc/lighttpd/lighttpd.conf + + # just in case + sudo chown -R root:root /srv/http + sudo chmod 755 /srv/http/cgi-bin + sudo systemctl restart lighttpd diff --git a/README b/README @@ -1,3 +1,27 @@ ojudge ====== OCaml-based competitive programming judging platform using CGI and podman. + +architecture +============ + +web server +---------- + +the web server is lighttpd for CGI. This calls OCaml binaries which manage +interactivity. Dispatching containers to evaluate solutions is performed by a daemon +to ensure we 1) limit the number of concurrent executions 2) don't block the CGI processes +from returning after submissions. + +daemon +------ + +there's a daemon that runs on the bare host, looking for submissions that haven't been evaluated +or dispatched. It also limits concurrency to two containers at a time. + +containers +---------- + +each submission runs in its own container, started by the dispatching daemon. + +see containers/arch.txt for container design diff --git a/cgi-bin/example.sh b/cgi-bin/example.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +echo "Hello, world!!!" +echo $(whoami) diff --git a/cgi-bin/home.sh b/cgi-bin/home.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo "<h1>This is the home! </h1>" diff --git a/lighttpd.conf b/lighttpd.conf @@ -0,0 +1,27 @@ +# This is a minimal example config +# See /usr/share/doc/lighttpd +# and https://wiki.lighttpd.net/Docs:ConfigurationOptions + +server.username = "http" +server.groupname = "http" +server.document-root = "/srv/http" +dir-listing.activate = "enable" +index-file.names = ( "home.sh" ) +server.modules += ( + "mod_alias", + "mod_cgi", + "mod_rewrite" + ) + +alias.url += ( "/cgi-bin/" => "/srv/http/cgi-bin/" ) + +$HTTP["url"] =~ "^/cgi-bin/" { + cgi.assign = ( + ".sh" => "/bin/sh", + "" => "" + ) +} + +url.rewrite-once = ( + "^/(\?.*)?$" => "/cgi-bin/home.sh$1" +) diff --git a/scripts/example.sh b/scripts/example.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +echo "Hello, world!!!" +echo $(whoami) diff --git a/scripts/home.sh b/scripts/home.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo "<h1>This is the home! </h1>"