Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change configuration format from JSON to TOML #1224

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ RUN sudo python3 setup.py install

RUN sudo python3 prerequisites.py --yes --cmsuser=cmsuser install

RUN sudo sed 's|/cmsuser:your_password_here@localhost:5432/cmsdb"|/postgres@testdb:5432/cmsdbfortesting"|' ./config/cms.conf.sample \
| sudo tee /usr/local/etc/cms-testdb.conf
RUN sudo sed 's|/cmsuser:your_password_here@localhost:5432/cmsdb"|/postgres@devdb:5432/cmsdb"|' ./config/cms.conf.sample \
| sudo tee /usr/local/etc/cms-devdb.conf
RUN sudo sed 's|/cmsuser:your_password_here@localhost:5432/cmsdb"|/postgres@testdb:5432/cmsdbfortesting"|' ./config/cms.toml.sample \
| sudo tee /usr/local/etc/cms-testdb.toml
RUN sudo sed 's|/cmsuser:your_password_here@localhost:5432/cmsdb"|/postgres@devdb:5432/cmsdb"|' ./config/cms.toml.sample \
| sudo tee /usr/local/etc/cms-devdb.toml

ENV LANG C.UTF-8

Expand Down
157 changes: 157 additions & 0 deletions cms/cms_conf_legacy_mapping.toml.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
### System-wide ###

temp_dir = {{(temp_dir or "/tmp")|tojson}}

# Whether to have a backdoor (see doc for the risks).
backdoor = {{(backdoor or false)|tojson}}

# The user/group that CMS will be run as.
cmsuser = {{(cmsuser or "cmsuser")|tojson}}


### Database ###

# Connection string for the database.
database = {{(database or "postgresql+psycopg2://cmsuser:your_password_here@localhost:5432/cmsdb")|tojson}}

# Whether SQLAlchemy prints DB queries on stdout.
database_debug = {{(database_debug or false)|tojson}}

# Whether to use two-phase commit.
twophase_commit = {{(twophase_commit or false)|tojson}}


### Worker ###

# Don't delete the sandbox directory under /tmp/ when they
# are not needed anymore. Warning: this can easily eat GB
# of space very soon.
keep_sandbox = {{(keep_sandbox or false)|tojson}}


### Sandbox ###

# Do not allow contestants' solutions to write files bigger
# than this size (expressed in KB; defaults to 1 GB).
max_file_size = {{(max_file_size or 1048576)|tojson}}


### WebServers ###

# This key is used to encode information that can be seen
# by the user, namely cookies and auto-incremented
# numbers. It should be changed for each
# contest. Particularly, you should not use this example
# for other than testing. It must be a 16 bytes long
# hexadecimal number. You can easily create a key calling
# python -c 'from cmscommon import crypto; print(crypto.get_hex_random_key())'
secret_key = {{(secret_key or "8e045a51e4b102ea803c06f92841a1fb")|tojson}}

# Whether Tornado prints debug information on stdout.
tornado_debug = {{(tornado_debug or false)|tojson}}


### ContestWebServer ###

# Listening HTTP addresses and ports for the CWSs listed above
# in core_services. If you access them through a proxy (acting
# as a load balancer) running on the same host you could put
# 127.0.0.1 here for additional security.
contest_listen_address = {{(contest_listen_address or "")|tojson}}
contest_listen_port = {{(contest_listen_port or [8888])|tojson}}

# Login cookie duration in seconds. The duration is refreshed
# on every manual request.
contest_cookie_duration = {{(cookie_duration or 1800)|tojson}}

# If CWSs write submissions to disk before storing them in
# the DB, and where to save them. %s = DATA_DIR.
submit_local_copy = {{(submit_local_copy or true)|tojson}}
submit_local_copy_path = {{(submit_local_copy_path or "%s/submissions/")|tojson}}

# The number of proxies that will be crossed before CWSs get
# the request. This is used to decide whether to assume that
# the real source IP address is the one listed in the request
# headers or not. For example, if you're using nginx as a load
# balancer, you will likely want to set this value to 1.
contest_num_proxies_used = {{(num_proxies_used or 0)|tojson}}

# Maximum size of a submission in bytes. If you use a proxy
# and set these sizes to large values remember to change
# client_max_body_size in nginx.conf too.
max_submission_length = {{(max_submission_length or 100000)|tojson}}
max_input_length = {{(max_input_length or 5000000)|tojson}}

# STL documentation path in the system (exposed in CWS).
stl_path = {{(stl_path or "/usr/share/cppreference/doc/html/")|tojson}}


### AdminWebserver ###

# Listening HTTP address and port for the AWS. If you access
# it through a proxy running on the same host you could put
# 127.0.0.1 here for additional security.
admin_listen_address = {{(admin_listen_address or "")|tojson}}
admin_listen_port = {{(admin_listen_port or 8889)|tojson}}

# Login cookie duration for admins in seconds.
# The duration is refreshed on every manual request.
admin_cookie_duration = {{(admin_cookie_duration or 36000)|tojson}}

# The number of proxies that will be crossed before AWS gets
# the request. This is used to determine the request's real
# source IP address. For example, if you're using nginx as
# a proxy, you will likely want to set this value to 1.
admin_num_proxies_used = {{(admin_num_proxies_used or 0)|tojson}}


### ProxyService ###

# List of URLs (with embedded username and password) of the
# RWSs where the scores are to be sent. Don't include the
# load balancing proxy (if any), just the backends. If any
# of them uses HTTPS specify a file with the certificates
# you trust.
rankings = {{(rankings or ["http://usern4me:passw0rd@localhost:8890/"])|tojson}}
https_certfile = {{(https_certfile or "")|tojson}}


### PrintingService ###

# Maximum size of a print job in bytes.
max_print_length = {{(max_print_length or 10000000)|tojson}}

# Printer name (can be found out using 'lpstat -p';
# if "", printing is disabled)
printer = {{(printer or "")|tojson}}

# Output paper size (probably A4 or Letter)
paper_size = {{(paper_size or "A4")|tojson}}

# Maximum number of pages a user can print per print job
# (excluding the title page). Text files are cropped to this
# length. Too long pdf files are rejected.
max_pages_per_job = {{(max_pages_per_job or 10)|tojson}}
max_jobs_per_user = {{(max_jobs_per_user or 10)|tojson}}
pdf_printing_allowed = {{(pdf_printing_allowed or false)|tojson}}

{{stray}}

### Services ###

[core_services]

LogService = {{(core_services.LogService or [])|tojson}}
ResourceService = {{(core_services.ResourceService or [])|tojson}}
ScoringService = {{(core_services.ScoringService or [])|tojson}}
Checker = {{(core_services.Checker or [])|tojson}}
EvaluationService = {{(core_services.EvaluationService or [])|tojson}}
Worker = {{(core_services.Worker or [])|tojson}}
ContestWebServer = {{(core_services.ContestWebServer or [])|tojson}}
AdminWebServer = {{(core_services.AdminWebServer or [])|tojson}}
ProxyService = {{(core_services.ProxyService or [])|tojson}}
PrintingService = {{(core_services.PrintingService or [])|tojson}}

[other_services]

TestFileCacher = {{(other_services.TestFileCacher or [])|tojson}}
Loading
Loading