LRCLIB server written in Rust with Axum and SQLite3 database
LRCLIB server written in Rust with Axum and SQLite3 database
LRCLIB server written in Rust with Axum and SQLite3 database.
This is the source code of lrclib.net rewritten in Rust from scratch. LRCLIB is a completely free service for finding and contributing synchronized lyrics, with an easy-to-use and machine-friendly APIs.
Build the project:
cargo build --releaseRun the server:
LRCLIB_LOG=info cargo run --release -- serve --database db.sqlite3Server will be available at http://0.0.0.0:3300
You have three environment variables available to tweak the database connection:
LRCLIB_MMAP_SIZE (default 30000000000 - 30GB): set SQLite's mmap_size parameter. This should be less than 75% of the available RAM. Using an excessive value might cause memory swapping, decreasing performance.LRCLIB_CACHE_SIZE (default -1000000 - 1GB): set SQLite's cache_size parameter. Negative values are kilobytes.LRCLIB_POOL_MAX_SIZE (default 16): set the maximum number of SQLite connections managed by the r2d2 pool. The value must be a positive integer.Use these variables to optimize memory usage in low traffic and/or low memory situations. The default values are generously sized to be used on a production system.
Build the image:
podman build -t lrclib-rs:latest -f Dockerfile .Run the container:
podman run --rm -it -d -v lrclib-data:/data -p 3300:3300 -e LRCLIB_LOG=info --name lrclib-rs lrclib-rs:latestServer will be available at http://0.0.0.0:3300
Run the following command to directly interact with the database in command line:
podman run --rm -it -v lrclib-data:/data lrclib-rs:latest sqlite3 /data/db.sqlite3You can use Quadlet to run the Podman container in the background. It also handles auto-start the container after machine restart for you.
Create a file named lrclib.container at ~/.config/containers/systemd/:
mkdir -p $HOME/.config/containers/systemd/
vi $HOME/.config/containers/systemd/lrclib.containerThe example content of lrclib.container:
[Container]
Image=lrclib-rs:latest
PublishPort=3300:3300
Volume=lrclib-data:/data
ContainerName=lrclib-rs
Environment=LRCLIB_LOG=info
[Service]
Restart=always
[Install]
WantedBy=multi-user.target default.targetReload the daemon:
systemctl --user daemon-reloadStart the service:
systemctl --user start lrclib.serviceCheck the status to see if lrclib.service is actually running:
systemctl --user status lrclib.serviceRestart when the container image is updated:
systemctl --user restart lrclib.serviceToss a coin to your developer?
GitHub Sponsors (Recommended - 100% of your support goes to the developer):
https://github.com/sponsors/tranxuanthang
Buy Me a Coffee:
https://www.buymeacoffee.com/thangtran
Paypal:
https://paypal.me/tranxuanthang98
Monero (XMR):
43ZN5qDdGQhPGthFnngD8rjCHYLsEFBcyJjDC1GPZzVxWSfT8R48QCLNGyy6Z9LvatF5j8kSgv23DgJpixJg8bnmMnKm3b7Litecoin (LTC):
ltc1q7texq5qsp59gclqlwf6asrqmhm98gruvz94a48If you prefer to contact by email:
No open issues yet, or sync has not completed.