Add multi-instance support - #3725
Open
meisterT wants to merge 4 commits into
Open
Conversation
Member
Author
|
@vmcj this is the second half of my change |
| derives an *instance name* from the name of the directory the source tree | ||
| lives in, and uses it for | ||
|
|
||
| * the webserver and PHP-FPM configuration file names installed into |
Member
There was a problem hiding this comment.
I might have missed it, but shouldn't we also name the nginx/apache config files something with the instance in there when installing?
i.e. instead of /etc/nginx/snippets/domjudge-inner.conf (or something we did) we do /etc/nignx/snippets/domjudge-inner-{instance}.conf?
The path DOMjudge is served under was written twice and had to be kept in sync by hand: once as --with-baseurl, which only reaches etc/domserver-static.php and webapp/config/static.yaml, and again as a literal /domjudge in the Apache and nginx templates. Configuring a base URL therefore silently left the webserver configuration pointing somewhere else. Derive the prefix from the base URL instead. Since the two cases differ in kind rather than in value -- Apache needs DocumentRoot instead of Alias, and nginx has no meaningful empty-prefix form of the redirect -- add a small marker mechanism to the template substitution that keeps or drops whole lines depending on whether the prefix is empty. Note that nginx's 'set' directive requires two arguments, so the empty prefix has to be written as an explicit empty string. This changes the generated configuration for installations whose base URL has no path: they now get a configuration serving DOMjudge from the root, which is what their base URL says, rather than from /domjudge.
Everything DOMjudge installs outside its own prefix was named 'domjudge', so a second installation on the same host silently took over the first one's configuration: the Apache and nginx configuration files, the PHP-FPM pool file and the sudoers file all have fixed names, and the generated database credentials always name the database and its user 'domjudge'. Name all of those after a configurable instance instead. Note that the nginx upstream and the variable holding the HTTPS flag are global to nginx, so a duplicate is not merely confusing but makes nginx refuse to start. The name is sanitized so that it is usable as a file name, an nginx upstream name and a database user, and truncated to 24 characters since MySQL limits user names to 32. A name that reduces to nothing is an error rather than a silent fallback to the default instance. The default instance keeps every historic name, and also remains the catch-all server on port 80; only named instances take their server name and port from the base URL. Generated files are therefore unchanged for existing installations.
Working on several branches at once, e.g. with git worktree or jj workspace, meant only one checkout could have a working installation, since every in-place install used the same configuration file names and the same database. Derive the instance name and a matching base URL from the name of the directory the source tree lives in, so that a worktree needs no extra flags at all. A checkout named 'domjudge' keeps the historic defaults. Each instance is served under its own hostname rather than its own port or path, because browsers do not scope cookies by port and DOMjudge does not scope its session cookie to the base path; two instances sharing a hostname would keep invalidating each other's sessions. An empty derived name would be passed as --with-instance-name='', which configure treats as unset, so the tree would silently install itself as the default instance; refuse to configure in that case instead. Likewise, refuse to install a webserver configuration file that already belongs to a different source tree, which catches two directory names reducing to the same instance name.
meisterT
force-pushed
the
multi-instance-support
branch
from
September 3, 2026 20:56
75fd423 to
cc483f5
Compare
vmcj
reviewed
Sep 4, 2026
Co-authored-by: MCJ Vasseur <14887731+vmcj@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.