Skip to content

Components

SourceLab is split over several processes that share one Python package. Only the web application and its workers are required, along with a SQL database, a filesystem shared by all of them for the git repositories, and sshd if you want SSH access.

Most features follow this path: the web application answers the request, and hands anything slow to a worker as a job, written to a table of the database.

A browser or API client calls the web app. The web app uses the SQL database and git repositories directly, and puts slow work there as jobs. Myxo workers take the jobs, use the same stores, and call webhooks, mirrors and SMTP.

Git access takes a different route, over SSH or HTTP. Both end in the same git commands. A push runs SourceLab's hooks.

Over SSH, sshd runs keyhelper.py for key lookup and aclchecker.py as a forced command. Both call /pv/ssh/* on the web app, then aclchecker.py executes git-receive-pack or git-upload-pack. Over HTTP, the web app's ui/clone.py runs git http-backend, which starts the same commands. A push starts the hookrunner process, which uses the SQL database and puts jobs there.

Process Started by Required
Web application sourcelab_web (uvicorn), or files/sourcelab.wsgi Yes
Worker, the Myxo services projects, repos, pull_requests and stats sourcelab_worker (myxo serve) Yes
Git hooks git, on each push Yes
SSH helpers (keyhelper.py, aclchecker.py) sshd For SSH access
authorized_keys worker, the Myxo service keys sourcelab_authorized_keys_worker (myxo serve) No
Webhooks, commit log, JSON load sourcelab_webhook, sourcelab_logcom, sourcelab_loadjson (myxo serve) See below
Builds, the Myxo services builds, builds_blobs, builds_forge_accounts and builds_forge myxo serve, in the web application's process No
Build runners, the Myxo service builds_runner myxo serve, on their own machines For builds
Mirroring, the Myxo service mirror sourcelab_mirror (myxo serve) No
Documentation server sourcelab_docs_web No
Email replies sourcelab_milter No
Periodic jobs systemd timers No

The systemd units are in files/, except that of the email replies, which is in packages/sourcelab-milters/.

Core application

The core application is an ASGI application, written with Litestar. It provides a web UI to the git repositories, tickets and pull requests, along with a JSON API.

Workers

Working on git repositories can take a long time, depending on the size of the repository, the hardware and the load on the system. So the web application doesn't do it itself: dedicated workers do, asynchronously, while the user waits on a /wait page.

The workers are Myxo services. The web application and the git hooks put jobs in a table of the SQL database, myxo_jobs, in the transaction of their change, and the services take them from there. Each service runs in a process of the layout /etc/sourcelab/layout.toml, alone or with others, and myxo migrate creates the tables.

Services in their own process

Some services run in a process of their own, so that a slow third party can't hold up the rest:

  • Webhooks send notifications to third party services with HTTP POST requests. See Webhooks.
  • Commit log updates the log table on every push, which provides the data for the calendar heatmap on each user's page. See Log Commits.
  • JSON load updates the database from what was pushed to a ticket or pull request git repository. See Load JSON.

Warning

A job only runs if a process of the layout runs its service. Without one, the application still puts the jobs and reports no error: they just pile up in the database. So if you need one of these features, make sure that its service is running.

Optional services

The first two run as their own processes, outside the main application.

Two separate paths. Email replies: the MTA hands mail to sourcelab-milters, which finds the sender in SQL and sends a PUT comment to /pv. Project docs: docs_server, on a separate domain, serves browsers from the docs git repositories and SQL.

Documentation server

This server displays the documentation that users provide for their projects. Since displaying content provided by users is a security risk, it is separate from the main application. We strongly encourage you to run it on a completely different domain name (not just a subdomain) to reduce the cross-site forgery risks.

SourceLab runs fine without it: just don't define DOC_APP_URL in the configuration file.

Milter

The milter lets people reply to a comment on a ticket or a pull request by replying to the notification email. It integrates with an MTA such as postfix or sendmail, whose configuration you need to be able to change. See Email Replies.

Builds

The builds run the manifests of a project's repository on each push, as builds.sr.ht does, on runners: other machines, which run each job in a fresh container and take nothing but jobs from the forge. They are a plugin, the sourcelab-builds package. See Builds.

Live updates

The web application can refresh the issue and pull request pages while someone is viewing them: if someone comments on the ticket you're reading, the comment shows up without reloading the page. It publishes each change on redis, and sends it to the pages that follow it as server-sent events. This takes a redis server, but no process of its own. See Live Updates.