discord test stars

About

The Mys programming language website and package registry implemented in the Mys programming language.

Project: https://github.com/mys-lang/package-website

Testing

Run the test suite.

make test

Run locally

Start an webserver locally. Run mys run -- --help for options.

 mys run
 Reading package configuration (0 seconds)
 Getting compiler flags openssl (0.01 seconds)
 Getting linker flags for openssl (0 seconds)
 Getting compiler flags sqlite3 (0 seconds)
 Getting linker flags for sqlite3 (0.01 seconds)
 Building (5.62 seconds)
Number of packages: 0
Listening for clients on port 8000.

Installation

Nginx terminates SSL/TLS.

/etc/nginx/conf.d/mys-lang.org.conf:

server {
    listen 80 http2;
    server_name mys-lang.org;
    client_max_body_size 50M;
    gzip on;
    gzip_types image/svg+xml application/javascript application/json text/css text/html;

    location ^~ /.well-known/acme-challenge/ {
        root /var/www/mys-lang.org;
    }

    location / {
        if ($request_method ~* "(GET|POST)") {
          add_header "Access-Control-Allow-Origin"  *;
        }

        if ($request_method = OPTIONS) {
          add_header "Access-Control-Allow-Origin"  *;
          add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS, HEAD";
          add_header "Access-Control-Allow-Headers" *; #"Authorization, Origin, X-Requested-With, Content-Type, Accept";
          return 200;
        }

        proxy_pass          http://localhost:8000/;
        proxy_http_version  1.1;
        proxy_set_header    X-Forwarded-For  $proxy_add_x_forwarded_for;
    }
}

Install certbot.

https://www.nginx.com/blog/using-free-ssltls-certificates-from-lets-encrypt-with-nginx/

Create a certificate and automatically updates nginx configuration. Enable redirect of http to https.

sudo certbot --nginx -d mys-lang.org

Run once in a while to renew the certificate.

sudo certbot renew

ZFS storage with compression and deduplication

There are lots of identical files in releases. Dedup saves disk space. So does compression with LZ4. Not sure about the combination of the two.

$ sudo dd if=/dev/zero of=/home/mys/database.img bs=4096 count=262144
$ sudo zpool create mys-website /home/mys/database.img
$ sudo zpool set autoexpand=on mys-website
$ sudo zfs create mys-website/database
$ sudo zfs set compression=lz4 mys-website/database
$ sudo zfs set dedup=on mys-website/database
$ sudo zfs set mountpoint=/home/mys/database mys-website/database
$ zpool list
NAME          SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT
mys-website   960M  15.1M   945M        -         -     0%     1%  79.76x    ONLINE  -

Systemd service

/etc/systemd/system/mys-lang.org.service

[Unit]
Description=Mys website
After=network.target
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=always
RestartSec=1
User=mys
ExecStart=/home/mys/.local/bin/website -d /home/mys/database [-i <ipinfo-token>]
WorkingDirectory=/home/mys
KillSignal=SIGINT

[Install]
WantedBy=multi-user.target

Enable it for automatic start at boot.

sudo systemctl enable mys-lang.org

Start it.

sudo systemctl start mys-lang.org