- OCaml 78%
- Shell 10%
- Makefile 7%
- JavaScript 5%
reminders.bayge.xyz #
A deliberately small personal reminders PWA. It is one standalone OCaml/Eio HTTP server;
the only runtime state is reminders.json.
Build #
opam install dune cohttp-eio eio_main yojson
dune build
The executable is _build/default/reminders_bayge.exe.
Run #
Listen on loopback TCP port 8080:
env REMINDERS_FILE=/var/lib/reminders/reminders.json REMINDERS_STATIC_DIR=/opt/reminders/static ./reminders_bayge.exe
Listen on a Unix socket instead:
env REMINDERS_FILE=/var/lib/reminders/reminders.json REMINDERS_STATIC_DIR=/opt/reminders/static ./reminders_bayge.exe --socket /run/reminders/reminders.sock
The process removes a stale socket before listening and creates the new socket with mode
0660. The parent directory must already exist and be writable by the process user.
For deployment, run.sh starts the bundled executable under Firejail. It permits only Unix
sockets, disables the network namespace, drops capabilities, and makes the filesystem
read-only except for the state-file and socket directories:
REMINDERS_FILE=/var/lib/reminders/reminders.json \
REMINDERS_SOCKET=/run/reminders/reminders.sock \
./run.sh
The defaults are reminders.json and static/ beside the script, with the socket at
/run/reminders/reminders.sock. The service user must own or be able to write the two
parent directories. Install Firejail on the server before using the script.
systemd #
The included reminders-bayge.service runs the Firejail wrapper as reminders-bayge.
It expects this layout:
/home/reminders-bayge/reminders_bayge
/home/reminders-bayge/run.sh
/home/reminders-bayge/static/
Install and start it:
sudo install -m 0644 /home/reminders-bayge/reminders-bayge.service /etc/systemd/system/reminders-bayge.service
sudo systemctl daemon-reload
sudo systemctl enable --now reminders-bayge.service
sudo systemctl status reminders-bayge.service
The unit creates /var/lib/reminders-bayge for state and /run/reminders-bayge for the
socket. It runs with group www-data, allowing nginx to connect to:
/run/reminders-bayge/reminders.sock
If the reverse proxy uses another group, change Group=www-data in the unit before
installing it. Do not add NoNewPrivileges=yes to the systemd unit: Firejail normally
uses its setuid launcher to construct the sandbox and applies no-new-privileges to the
application itself.
Other options:
--port PORT TCP port; default 8080
--listen-all bind TCP to 0.0.0.0 instead of 127.0.0.1
The server directly serves the application, /tasks-api, the manifest, service worker, and
icons. No CGI or FastCGI adapter is needed.
A minimal nginx location for a Unix socket is:
location / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://unix:/run/reminders/reminders.sock;
}
The mutation routes accept application/x-www-form-urlencoded POST bodies. /tasks-api
returns one visible task per line as name<TAB>posted<TAB>id.