From ed6e11c91880526d6cdf976a71e7925f109f156f Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Sun, 10 Oct 2021 11:03:24 -0700 Subject: [PATCH 01/11] [#127] Fix A+ redirect loop --- langs/aplus.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/langs/aplus.yaml b/langs/aplus.yaml index 6c0552a..3fda1bc 100644 --- a/langs/aplus.yaml +++ b/langs/aplus.yaml @@ -2,7 +2,6 @@ id: "aplus" aliases: - "a+" - "ap" - - "aplus" name: "A+" install: From 681ed30bcfc6ee0dd137fbf7453dfa9f21ca5e83 Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Sun, 10 Oct 2021 11:24:06 -0700 Subject: [PATCH 02/11] [#41] Fix segfault for eC --- langs/ec.yaml | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/langs/ec.yaml b/langs/ec.yaml index 73a26a8..d01c606 100644 --- a/langs/ec.yaml +++ b/langs/ec.yaml @@ -29,6 +29,31 @@ install: - libjpeg-turbo8 - libpng16-16 - libxrender1 + files: + "/opt/ec/skel/main.epj": | + { + "Version": 0.2, + "ModuleName": "main", + "Options": { + "Warnings": "All", + "TargetType": "Executable", + "TargetFileName": "main", + "Libraries": ["ecere"] + }, + "Configurations": [ + { + "Name": "Release", + "Options": { + "Debug": false, + "Optimization": "Speed", + "FastMath": true + } + } + ], + "Files": ["main.ec"], + "ResourcesPath": "", + "Resources": [] + } # Release 0.44.15 failed to compile with "multiple definition" # errors from ld, so use the master branch instead. manual: | @@ -48,14 +73,11 @@ template: | } } +setup: | + cp -R /opt/ec/skel/* "$PWD/" + epj2make -o Makefile main.epj >/dev/null + compile: | - export LD_LIBRARY_PATH=/usr/local/lib/ec - ecp -c main.ec -o main.sym - ecc -c main.ec -o main.c - ecs -console main.sym main.imp -o main.main.ec - ecp -c main.main.ec -o main.main.sym - ecc -c main.main.ec -o main.main.c - clang main.c main.main.c -lecereCOM -o main + make LD_LIBRARY_PATH=/usr/local/lib/ec run: | - ./main -helloStatus: 139 + ./obj/release.linux/main From 53980f77880e5f436398a95b7fd494c05ee89347 Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Sun, 17 Oct 2021 13:07:21 -0700 Subject: [PATCH 03/11] We receive donations now --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bd037c1..1a74c56 100644 --- a/README.md +++ b/README.md @@ -44,8 +44,9 @@ being nice include: * *Trying to consume as many resources as possible.* All this will do is prevent others from using Riju, which isn't nice. -* *Mining cryptocurrency.* Since hosting Riju comes out of my - paycheck, this is exactly equivalent to stealing, which isn't nice. +* *Mining cryptocurrency.* Since hosting Riju comes out of ~my + paycheck~ community donations, this is exactly equivalent to + stealing, which isn't nice. ## Can I help? / Documentation From bc900174a987c0d8434f37295938d6f055453a7f Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Fri, 22 Oct 2021 12:50:30 -0700 Subject: [PATCH 04/11] [#129] Upgrade t3.medium => t3.large --- tf/ec2.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tf/ec2.tf b/tf/ec2.tf index 83ccee9..9f31e58 100644 --- a/tf/ec2.tf +++ b/tf/ec2.tf @@ -37,7 +37,7 @@ resource "aws_security_group" "server" { resource "aws_launch_template" "server" { name = "riju-server" image_id = data.aws_ami.server.id - instance_type = "t3.medium" + instance_type = "t3.large" security_group_names = [aws_security_group.server.name] iam_instance_profile { From 0d92a7792235e48e1b84a095eec5e1bd1febc2b9 Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Sun, 24 Oct 2021 12:32:08 -0700 Subject: [PATCH 05/11] [#129] Tune cgroup resources Should help by giving 3GB headroom instead of 1GB for the server and operating system. Empirically, it looks like the OOM killer is operating properly and killing user code rather than system processes, but the small amount of headroom could have been a problem. Extensive usage of swap could also have been a problem so I disabled swap for user code. Reduced the CPU quota to eliminate access to bursting from user code, as well, and bumped the pid quota because we had a lot of headroom there. --- packer/riju.slice | 22 ++++++++++++++++++---- system/src/riju-system-privileged.c | 6 ++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/packer/riju.slice b/packer/riju.slice index a670120..c3e9eca 100644 --- a/packer/riju.slice +++ b/packer/riju.slice @@ -3,12 +3,26 @@ Description=Resource limits for Riju user containers Before=slices.target [Slice] + +# t3.large instance has baseline CPU performance of 60% and is +# burstable up to 200%. Reserve bursting for server + operating +# system. CPUAccounting=true -CPUQuota=100% +CPUQuota=60% + +# t3.large instance has 8GB memory, so reserve 3GB for server + +# operating system. Disable swap for now. MemoryAccounting=true -MemoryMax=3G -MemorySwapMax=8G +MemoryMax=5G +MemorySwapMax=0 + +# Empirically, EC2 instances appear to have /proc/sys/kernel/pid_max +# equal to 2^22 = 4194304. It should be safe to give about a tenth of +# this space to user code. TasksAccounting=true -TasksMax=2048 +TasksMax=400000 + +# Attempt to deny access to EC2 Instance Metadata service from user +# code. IPAccounting=true IPAddressDeny=169.254.169.254 diff --git a/system/src/riju-system-privileged.c b/system/src/riju-system-privileged.c index 71fa582..91f2025 100644 --- a/system/src/riju-system-privileged.c +++ b/system/src/riju-system-privileged.c @@ -233,13 +233,11 @@ void session(char *uuid, char *lang, char *imageHash) "--name", container, "--cpus", - "1", + "0.6", "--memory", "1g", - "--memory-swap", - "8g", "--pids-limit", - "2048", + "4000", "--cgroup-parent", "riju.slice", "--label", From b0210f8f4c654d051a32b37a6f38d4cc7d5fca95 Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Sat, 6 Nov 2021 13:41:17 -0700 Subject: [PATCH 06/11] Migrate to advanced Fathom Analytics Allow interpolating an arbitrary analytics tag. --- Makefile | 2 +- backend/server.js | 6 +++--- doc/selfhosting.md | 6 +++--- frontend/pages/app.ejs | 4 ++-- frontend/pages/index.ejs | 4 ++-- packer/provision-web.bash | 2 +- packer/riju.service | 2 +- packer/web.pkr.hcl | 6 +++--- supervisor/src/main.go | 2 +- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index aad9d3e..819a0b4 100644 --- a/Makefile +++ b/Makefile @@ -73,7 +73,7 @@ else SHELL_PORTS := endif -SHELL_ENV := -e Z -e CI -e TEST_PATIENCE -e TEST_CONCURRENCY -e TEST_TIMEOUT_SECS -e FATHOM_SITE_ID +SHELL_ENV := -e Z -e CI -e TEST_PATIENCE -e TEST_CONCURRENCY -e TEST_TIMEOUT_SECS -e ANALYTICS_TAG ifeq ($(I),lang) LANG_TAG := lang-$(L) diff --git a/backend/server.js b/backend/server.js index 3045370..63305c3 100644 --- a/backend/server.js +++ b/backend/server.js @@ -15,7 +15,7 @@ const host = process.env.HOST || "localhost"; const port = parseInt(process.env.PORT || "") || 6119; const tlsPort = parseInt(process.env.TLS_PORT || "") || 6120; const useTLS = process.env.TLS ? true : false; -const fathomSiteId = process.env.FATHOM_SITE_ID || ""; +const analyticsTag = process.env.ANALYTICS_TAG || ""; const langs = await langsPromise; const app = express(); @@ -27,7 +27,7 @@ app.get("/", (_, res) => { if (Object.keys(langs).length > 0) { res.render(path.resolve("frontend/pages/index"), { langs, - fathomSiteId, + analyticsTag, }); } else { res @@ -61,7 +61,7 @@ app.get("/:lang", (req, res) => { } res.render(path.resolve("frontend/pages/app"), { config: langs[lang], - fathomSiteId, + analyticsTag, }); }); app.use("/css", express.static("frontend/styles")); diff --git a/doc/selfhosting.md b/doc/selfhosting.md index 60f62f2..35ef4ab 100644 --- a/doc/selfhosting.md +++ b/doc/selfhosting.md @@ -263,9 +263,9 @@ enable all the fun CloudFlare options you'd like. ## Set up analytics (optional) -Sign up for Fathom Analytics, enter your domain name, and get a site -ID. Set this as `FATHOM_SITE_ID` in your `.env` file, and build and -roll out a new web AMI. +Sign up for Fathom Analytics, enter your domain name, and get a tag +for embedding. Set this as `ANALYTICS_TAG` in your `.env` file (don't +forget the appropriate quoting), and build and roll out a new web AMI. ## Set up monitoring (optional) diff --git a/frontend/pages/app.ejs b/frontend/pages/app.ejs index b2db5a3..495d279 100644 --- a/frontend/pages/app.ejs +++ b/frontend/pages/app.ejs @@ -22,8 +22,8 @@ window.rijuConfig = <%- JSON.stringify(config) %>; - <% if (fathomSiteId) { %> - + <% if (analyticsTag) { %> + <%= analyticsTag %> <% } %> diff --git a/frontend/pages/index.ejs b/frontend/pages/index.ejs index 77c1830..fe25f16 100644 --- a/frontend/pages/index.ejs +++ b/frontend/pages/index.ejs @@ -30,8 +30,8 @@ <% } else { %> Riju is loading language configuration... <% } %> - <% if (fathomSiteId) { %> - + <% if (analyticsTag) { %> + <%= analyticsTag %> <% } %> diff --git a/packer/provision-web.bash b/packer/provision-web.bash index 62a4bb1..dac1f74 100644 --- a/packer/provision-web.bash +++ b/packer/provision-web.bash @@ -59,7 +59,7 @@ sudo sed -Ei 's|^#?PermitRootLogin .*|PermitRootLogin no|' /etc/ssh/sshd_config sudo sed -Ei 's|^#?PasswordAuthentication .*|PasswordAuthentication no|' /etc/ssh/sshd_config sudo sed -Ei 's|^#?PermitEmptyPasswords .*|PermitEmptyPasswords no|' /etc/ssh/sshd_config sudo sed -Ei "s|\\\$AWS_REGION|${AWS_REGION}|" /etc/systemd/system/riju.service -sudo sed -Ei "s|\\\$FATHOM_SITE_ID|${FATHOM_SITE_ID:-}|" /etc/systemd/system/riju.service +sudo sed -Ei "s|\\\$ANALYTICS_TAG|${ANALYTICS_TAG:-}|" /etc/systemd/system/riju.service sudo sed -Ei "s|\\\$S3_BUCKET|${S3_BUCKET}|" /etc/systemd/system/riju.service sudo sed -Ei "s|\\\$SENTRY_DSN|${SENTRY_DSN:-}|" /etc/systemd/system/riju.service sudo sed -Ei "s|\\\$SUPERVISOR_ACCESS_TOKEN|${SUPERVISOR_ACCESS_TOKEN}|" /etc/systemd/system/riju.service diff --git a/packer/riju.service b/packer/riju.service index 2697900..6e11ccf 100644 --- a/packer/riju.service +++ b/packer/riju.service @@ -11,7 +11,7 @@ ExecStart=riju-supervisor Restart=always RestartSec=5 Environment=AWS_REGION=$AWS_REGION -Environment=FATHOM_SITE_ID=$FATHOM_SITE_ID +Environment=ANALYTICS_TAG=ANALYTICS_TAG Environment=S3_BUCKET=$S3_BUCKET Environment=SENTRY_DSN=$SENTRY_DSN Environment=SUPERVISOR_ACCESS_TOKEN=$SUPERVISOR_ACCESS_TOKEN diff --git a/packer/web.pkr.hcl b/packer/web.pkr.hcl index 4ed4b3f..c20557a 100644 --- a/packer/web.pkr.hcl +++ b/packer/web.pkr.hcl @@ -8,9 +8,9 @@ variable "aws_region" { default = "${env("AWS_REGION")}" } -variable "fathom_site_id" { +variable "analytics_tag" { type = string - default = "${env("FATHOM_SITE_ID")}" + default = "${env("ANALYTICS_TAG")}" } variable "grafana_api_key" { @@ -116,7 +116,7 @@ build { environment_vars = [ "ADMIN_PASSWORD=${var.admin_password}", "AWS_REGION=${var.aws_region}", - "FATHOM_SITE_ID=${var.fathom_site_id}", + "ANALYTICS_TAG=${var.analytics_tag}", "GRAFANA_API_KEY=${var.grafana_api_key}", "S3_BUCKET=${var.s3_bucket}", "SENTRY_DSN=${var.sentry_dsn}", diff --git a/supervisor/src/main.go b/supervisor/src/main.go index 54c829b..2600475 100644 --- a/supervisor/src/main.go +++ b/supervisor/src/main.go @@ -355,7 +355,7 @@ func (sv *supervisor) reload() error { "-v", "/var/cache/riju:/var/cache/riju", "-v", "/var/run/docker.sock:/var/run/docker.sock", "-p", fmt.Sprintf("127.0.0.1:%d:6119", port), - "-e", "FATHOM_SITE_ID", + "-e", "ANALYTICS_TAG", "-e", "RIJU_DEPLOY_CONFIG", "-e", "SENTRY_DSN", "--label", fmt.Sprintf("riju.deploy-config-hash=%s", deployCfgHash), From 416a29ea2082ec62959ce27d60031ce941926e42 Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Sat, 6 Nov 2021 14:04:02 -0700 Subject: [PATCH 07/11] Add financial info for October 2021 --- financials/2021-10/breakdown.txt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 financials/2021-10/breakdown.txt diff --git a/financials/2021-10/breakdown.txt b/financials/2021-10/breakdown.txt new file mode 100644 index 0000000..e7b0510 --- /dev/null +++ b/financials/2021-10/breakdown.txt @@ -0,0 +1,18 @@ +Riju :: $106.77 + EC2 :: $81.38 + Data Transfer :: $0.03 + EBS Snapshot :: $2.36 + EBS Volume :: $28.57 + EBS Volume :: $28.57 + gp2 :: $1.07 + gp3 :: $27.49 + Instance :: $50.43 + t3.large :: $23.05 + t3.medium :: $27.38 + ECR :: $5.14 + Storage :: $5.14 + ELB :: $20.14 + Data Transfer :: $0.38 + LCUs :: $0.07 + Load Balancer :: $19.68 + S3 :: $0.11 From dde8f9eba3bc5bd6eae75e78dcbe4347bc2ce7fa Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Sat, 6 Nov 2021 14:28:18 -0700 Subject: [PATCH 08/11] Upgrade server to Ubuntu 21.10 --- packer/web.pkr.hcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packer/web.pkr.hcl b/packer/web.pkr.hcl index c20557a..ff1125f 100644 --- a/packer/web.pkr.hcl +++ b/packer/web.pkr.hcl @@ -35,7 +35,7 @@ variable "supervisor_access_token" { data "amazon-ami" "ubuntu" { filters = { - name = "ubuntu/images/hvm-ssd/ubuntu-*-21.04-amd64-server-*" + name = "ubuntu/images/hvm-ssd/ubuntu-*-21.10-amd64-server-*" root-device-type = "ebs" virtualization-type = "hvm" } From 1b529af997c8df4e73c8c607c89ed4599f20a149 Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Sun, 7 Nov 2021 09:32:05 -0800 Subject: [PATCH 09/11] Fix typo --- packer/riju.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packer/riju.service b/packer/riju.service index 6e11ccf..c11177b 100644 --- a/packer/riju.service +++ b/packer/riju.service @@ -11,7 +11,7 @@ ExecStart=riju-supervisor Restart=always RestartSec=5 Environment=AWS_REGION=$AWS_REGION -Environment=ANALYTICS_TAG=ANALYTICS_TAG +Environment=ANALYTICS_TAG=$ANALYTICS_TAG Environment=S3_BUCKET=$S3_BUCKET Environment=SENTRY_DSN=$SENTRY_DSN Environment=SUPERVISOR_ACCESS_TOKEN=$SUPERVISOR_ACCESS_TOKEN From 18bfc4b0c58e1a5ae538b9ccb4c325dece359342 Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Sun, 7 Nov 2021 09:40:29 -0800 Subject: [PATCH 10/11] [#138] Add line numbers to C# stack traces --- langs/csharp.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/langs/csharp.yaml b/langs/csharp.yaml index e81e811..3988f44 100644 --- a/langs/csharp.yaml +++ b/langs/csharp.yaml @@ -19,9 +19,9 @@ template: | } compile: | - mcs main.cs + mcs -debug main.cs run: | - mono main.exe + mono --debug main.exe format: run: | From b2de59634297892baa6bd0c87ca16edc6037c002 Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Sun, 7 Nov 2021 10:29:34 -0800 Subject: [PATCH 11/11] Mess around more with analytics tag --- backend/server.js | 5 ++++- doc/selfhosting.md | 5 +++-- frontend/pages/app.ejs | 2 +- frontend/pages/index.ejs | 6 +++--- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/backend/server.js b/backend/server.js index 63305c3..457a679 100644 --- a/backend/server.js +++ b/backend/server.js @@ -15,7 +15,10 @@ const host = process.env.HOST || "localhost"; const port = parseInt(process.env.PORT || "") || 6119; const tlsPort = parseInt(process.env.TLS_PORT || "") || 6120; const useTLS = process.env.TLS ? true : false; -const analyticsTag = process.env.ANALYTICS_TAG || ""; +const analyticsTag = (process.env.ANALYTICS_TAG || "").replace( + /^'(.+)'$/, + "$1" +); const langs = await langsPromise; const app = express(); diff --git a/doc/selfhosting.md b/doc/selfhosting.md index 35ef4ab..43bb580 100644 --- a/doc/selfhosting.md +++ b/doc/selfhosting.md @@ -264,8 +264,9 @@ enable all the fun CloudFlare options you'd like. ## Set up analytics (optional) Sign up for Fathom Analytics, enter your domain name, and get a tag -for embedding. Set this as `ANALYTICS_TAG` in your `.env` file (don't -forget the appropriate quoting), and build and roll out a new web AMI. +for embedding. Set this as `ANALYTICS_TAG` in your `.env` file (use +single quoting, as Makefile handling of quotes is a bit nonstandard), +and build and roll out a new web AMI. ## Set up monitoring (optional) diff --git a/frontend/pages/app.ejs b/frontend/pages/app.ejs index 495d279..4b56337 100644 --- a/frontend/pages/app.ejs +++ b/frontend/pages/app.ejs @@ -23,7 +23,7 @@ <% if (analyticsTag) { %> - <%= analyticsTag %> + <%- analyticsTag %> <% } %> diff --git a/frontend/pages/index.ejs b/frontend/pages/index.ejs index fe25f16..ac45a26 100644 --- a/frontend/pages/index.ejs +++ b/frontend/pages/index.ejs @@ -4,6 +4,9 @@ Riju + <% if (analyticsTag) { %> + <%- analyticsTag %> + <% } %>

Riju: fast online playground for every programming language

@@ -30,8 +33,5 @@ <% } else { %> Riju is loading language configuration... <% } %> - <% if (analyticsTag) { %> - <%= analyticsTag %> - <% } %>