Skip to content

Instantly share code, notes, and snippets.

@danielpclin
Last active January 16, 2023 08:19
Show Gist options
  • Save danielpclin/43b0bc33be1e8596ceeea5d6f5b3f47b to your computer and use it in GitHub Desktop.
Save danielpclin/43b0bc33be1e8596ceeea5d6f5b3f47b to your computer and use it in GitHub Desktop.
DMOJ sample files
[program:bridged]
command=/opt/dmoj/venv/bin/python manage.py runbridged
directory=/opt/dmoj/site
stopsignal=INT
# You should create a dedicated user for the bridged to run under.
user=dmoj
group=dmoj
stdout_logfile=/opt/dmoj/bridge.stdout.log
stderr_logfile=/opt/dmoj/bridge.stderr.log
[program:celery]
command=/opt/dmoj/venv/bin/celery -A dmoj_celery worker
directory=/opt/dmoj/site
# You should create a dedicated user for celery to run under.
user=dmoj
group=dmoj
stdout_logfile=/opt/dmoj/celery.stdout.log
stderr_logfile=/opt/dmoj/celery.stderr.log
server {
listen 80;
listen [::]:80;
# Change port to 443 and do the nginx ssl stuff if you want it.
# Change server name to the HTTP hostname you are using.
# You may also make this the default server by listening with default_server,
# if you disable the default nginx server declared.
server_name <hostname>;
add_header X-UA-Compatible "IE=Edge,chrome=1";
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
charset utf-8;
try_files $uri @icons;
error_page 502 504 /502.html;
location ~ ^/502\.html$|^/logo\.png$|^/robots\.txt$ {
root /opt/dmoj/site;
}
location @icons {
root /opt/dmoj/site/resources/icons;
error_page 403 = @uwsgi;
error_page 404 = @uwsgi;
}
location @uwsgi {
uwsgi_read_timeout 600;
# Change this path if you did so in uwsgi.ini
uwsgi_pass unix:///opt/dmoj/dmoj-site.sock;
include uwsgi_params;
uwsgi_param SERVER_SOFTWARE nginx/$nginx_version;
}
location /static {
gzip_static on;
expires max;
root /opt/dmoj;
# Comment out root, and use the following if it doesn't end in /static.
#alias <STATIC_ROOT>;
}
# Uncomment if you are using PDFs and want to serve it faster.
# This location name should be set to DMOJ_PDF_PROBLEM_INTERNAL.
#location /pdfcache {
# internal;
# root <path to pdf cache directory, without the final /pdfcache>;
# # Default from docs:
# #root /home/dmoj-uwsgi/;
#}
# Uncomment if you are allowing user data downloads and want to serve it faster.
# This location name should be set to DMOJ_USER_DATA_INTERNAL.
#location /datacache {
# internal;
# root <path to data cache directory, without the final /datacache>;
# # Default from docs:
# #root /home/dmoj-uwsgi/;
#}
# Uncomment these sections if you are using the event server.
#location /event/ {
# proxy_pass http://127.0.0.1:<event server websocket port>/;
# proxy_http_version 1.1;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection "upgrade";
# proxy_read_timeout 86400;
#}
#location /channels/ {
# proxy_read_timeout 120;
# proxy_pass http://127.0.0.1:<event server http port>;
#}
}
[program:uwsgi]
command=/opt/dmoj/venv/bin/uwsgi --ini uwsgi.ini
directory=/opt/dmoj/site
stopsignal=QUIT
stdout_logfile=/opt/dmoj/uwsgi.stdout.log
stderr_logfile=/opt/dmoj/uwsgi.stderr.log
[uwsgi]
# Socket and pid file location/permission.
uwsgi-socket = /opt/dmoj/dmoj-site.sock
chmod-socket = 666
pidfile = /opt/dmoj/dmoj-site.pid
# You should create an account dedicated to running dmoj under uwsgi.
uid = dmoj
gid = dmoj
# Paths.
chdir = /opt/dmoj/site
pythonpath = /opt/dmoj/site
virtualenv = /opt/dmoj/venv
# Details regarding DMOJ application.
protocol = uwsgi
master = true
env = DJANGO_SETTINGS_MODULE=dmoj.settings
module = dmoj.wsgi:application
optimize = 2
# Scaling settings. Tune as you like.
memory-report = true
cheaper-algo = backlog
cheaper = 3
cheaper-initial = 5
cheaper-step = 1
cheaper-rss-limit-soft = 201326592
cheaper-rss-limit-hard = 234881024
workers = 7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment