Lada: Difference between revisions
(add databases section) |
m (→RAMdb: add details and fix typos) |
||
Line 53: | Line 53: | ||
=== RAMdb === | === RAMdb === | ||
Volatile database, keeps its data in <code>/mnt/ramdb/</code> which also is a 2GB <code>tmpfs</code> RAMdisk. This database has a dbname <code>sponsorblock</code> and a table <code>sponsorblock</code> that holds <code>sponsorTimes.csv</code> data for database-access instead of forcing the weberver to read a 1GB .csv with php. The volatility though is mostly for backup purposes : to avoid redundancy. The | Volatile database, keeps its data in <code>/mnt/ramdb/</code> which also is a 2GB <code>tmpfs</code> RAMdisk. This database has a dbname <code>sponsorblock</code> and a table <code>sponsorblock</code> that holds <code>sponsorTimes.csv</code> data for database-access instead of forcing the weberver to read a 1GB <code>.csv</code> with php. The volatility though is mostly for backup purposes: to avoid redundancy. The source of truth for that data is from the internet, but locally it is the <code>.csv</code>. Because that file is located in <code>/youtube</code>, it is backed up. The database would then only be backed up for the schema. The sponsorblock table was in the [[Lada#Normal postgresql database|normal database]] before, but it changes so fast that the about-biweekly backup of the entire container ballooned from about 2.5GB up to 16GB per snapshot, and 25+GB for multiple snapshots. Now only the <code>/mnt/ramdb_init/</code> data is backed up, about 20MB and generally static. | ||
==== /mnt/ramdb_init ==== | ==== /mnt/ramdb_init ==== | ||
Contains empty database instance for copying over to the tmpfs upon container boot. It is a database with the <code>sponsorblock</code> table and its indexes, just with 0 rows. On startup, the <code>ramdb</code> systemd service starts <code>/root/ramdb.sh</code> which sets the entire RAM database up and populates it by running <code>/home/user/addcsv.py</code> as <code>user</code>. | Contains empty database instance for copying over to the tmpfs upon container boot. It is a database with the <code>sponsorblock</code> table and its indexes, just with 0 rows. The configuration also states that the running port is 5433 to prevent conflict with the normal database (on default port 5432). On startup, the <code>ramdb</code> systemd service starts <code>/root/ramdb.sh</code> which sets the entire RAM database up and populates it by running <code>/home/user/addcsv.py</code> as <code>user</code> in a second thread. | ||
== External redirects == | == External redirects == |
Revision as of 21:18, 13 April 2022
LXC container
Webserver contents
Scripts in php display youtube, videos (TV series), movies, dlw and more. Video files are usually directly served but the php scripts always link to them as vlc://[lada https domain]/path/to/movie.mkv
to be handled on the client-side browser in a specific way, for example opening vlc
and streaming the https file over the network directly 'on-screen'.
Uploadable storage
/ram.php
shows downloadeable files and provides an uploading form, /ramulpoad.php
handes form and writes uploaded files to /var/www/html/ram/{filename}
. Under /var/www/html/ram/
there is a tmpfs
RAM filesystem mounted, to allow volatile operations, and therefore erasure across server reboots. It is mounted at boot by the systemd unit uploader
in /etc/systemd/system/uploader.service
.
Map
Makes cartography user-available in an interactive worldmap. /leaflet.html
handles display of the maps from raster tiles and manages all the layers. It uses the leaflet
javascript library, which is statically available in /leaflet/
. Rendered map layers are specified by a tile URL in the format /osm/{layername}/{z}/{x}/{y}.png
and any tile request will then be redirected to osm. Static raster tiles are directly mounted in the webserver, this is the case for one layer, /satellite/{z}/{x}/{y}.jpg
. /leaflet.html
also needs /leaflet.tilelayer.fallback.js
[1] for fallback-enabled layers, this is currently used for the /satellite/
layer as it does not have all tiles available. Instead of displaying the error tile whenever a specific tile is missing (/satellite/ocean.jpg
for /satellite/
), it reuses upper-zoom tiles and pixellates them.
Stats
Reads stats.json
from webserver root and displays it with Javascript library plotly
. Plotly.js
is statically loaded from the webserver to allow completely internet-less operation. stats.json
contains json data but it isprepended with "alldata=
" so that it is valid javascript and can be simply used in HTML:
<script src="/stats.json"></script>
The display then shows an interactive graph that allows zooming, panning and exporting view to .png
.
Arch and artix package mirror
Makes software zfs dataset available, all static files allow for package mirror operations. Use
Server = https://lada.tizarne.com/artix/$repo/os/$arch
for artix and
Server = https://lada.tizarne.com/arch/$repo/os/$arch
for arch in /etc/pacman.d/mirrorlist
. To make the two directories available in the webserver root, symlinks are used :
arch -> data/software/arch
artix -> data/software/artix
PHP scripts displaying data as user-accessible
These scripts may connect to a database and generate a HTML webpage to display video or audio data for display in a browser or as xml. This data is mostly readonly and for consumption, though the database may sometimes be written to regarding metadata like watching progress.
TV series
/videos
is a forced-php script that tracks watching progress in the database under dbname=video
. It displays all series on the landing page and makes a "watch next" vlc://
link available for each series. Some series that do not have ordered seasons will not have a global natch-next link, but on opening the series all seasons are shown and thos will have "watch next" links if the episodes are ordered. Unordered episodes means that in a season all episodes displayed have a green tick in the upper right corner if they have been watched. The entire script is server-side only and does not use javascript. It also features language track selection support by passing the ?audiolanguage={lang}
URL parameter in the vlc://
links and title specification through the URL parameter &title={urlencode(title)}
to be displayed in vlc
. The vlc opening script also needs to carefully parse URL parameters and only take those that refer to it, like audiolanguage
and title
. This is because the next
, next_season
and watch
URL parameters specify the mechanism to count episode progress. This takes place when vlc
fetches the URL: it will be to the /videos
script itself with some $_GET
parameters. This script will then update the database accordingly and only after that set the HTTP header 302 redirect to point to the video file for vlc
to start playing. This also allows for vlc to play the next track whenever the user presses "next", because the vlc
playlist has only one item, it will just refetch the same url. But because the php script has previously updated the database, it will again update the watching progress, and then redirect to the next video file in the sequence.
Podcast feeds
/feeds
is a forced-php script that connects to the database under dbname=audio
. It generates podcast xml feeds from the database. The audio files are also assumed to be under /data/audio/podcasts/{db_audio:podcasts:directory}/{db_audio:episodes:filename}
.
Forced php scripts
For cosmetic reasons and url shortness, some php scripts do not have a .php
extension. They are then manually forced to be php-interpreted in the server. This also allows to reference nonexisting subdirectories "under" the script : /youtube
is forced-php, and then /youtube/video/{videoid}
and /youtube/channel/{channelid}
are valid urls (that are also in practical use). Apache2 server configuration in /etc/apache2/apache2.conf
:
<FilesMatch "youtube|redirect|feeds|movies|dvd|videos">
ForceType application/x-httpd-php
SetHandler application/x-httpd-php
</FilesMatch>
The FilesMatch
section accepts regexes, so the a|b|c
syntax allows a shorthand for repeated <File a>...</File><File b>...</File>...
sections. This can become a security issue if the regex is edited to include wider syntax and more complicated regex parsing.
Databases
Normal postgresql database
Is started by systemd postgres
service and keeps data in /pgsql/data/
. Contains two dbnames videos
and audio
.
db videos
Biggest table is videos
which contains all youtube videos and their descriptions which contribute most to the size. Tables playlists
, channels
and others provide all youtube functionality for three types of resources: videos, channels and playlists.
Also contains all videos data in tables series
, seasons
and episodes
. They are only semi-automatically filled up, mostly through python. This happens through snippets in the history under /home/user/.python_history
.
RAMdb
Volatile database, keeps its data in /mnt/ramdb/
which also is a 2GB tmpfs
RAMdisk. This database has a dbname sponsorblock
and a table sponsorblock
that holds sponsorTimes.csv
data for database-access instead of forcing the weberver to read a 1GB .csv
with php. The volatility though is mostly for backup purposes: to avoid redundancy. The source of truth for that data is from the internet, but locally it is the .csv
. Because that file is located in /youtube
, it is backed up. The database would then only be backed up for the schema. The sponsorblock table was in the normal database before, but it changes so fast that the about-biweekly backup of the entire container ballooned from about 2.5GB up to 16GB per snapshot, and 25+GB for multiple snapshots. Now only the /mnt/ramdb_init/
data is backed up, about 20MB and generally static.
/mnt/ramdb_init
Contains empty database instance for copying over to the tmpfs upon container boot. It is a database with the sponsorblock
table and its indexes, just with 0 rows. The configuration also states that the running port is 5433 to prevent conflict with the normal database (on default port 5432). On startup, the ramdb
systemd service starts /root/ramdb.sh
which sets the entire RAM database up and populates it by running /home/user/addcsv.py
as user
in a second thread.
External redirects
Main website entry point and redirects some subdirectories to other webservers
/osm
to[osm]:80/
/kiwix
tolocalhost:8000/
/dewa
to[dewa]:8051/