Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/artemis-development-group/artemis/llms.txt

Use this file to discover all available pages before exploring further.

Artemis is composed of a main Python/Pylons application and a set of external services that handle persistence, caching, message delivery, and real-time features. This page describes what each service does, how Artemis uses it, and how to manage them all through Upstart.

Core infrastructure services

PostgreSQL

Stores relational data: user accounts, links, comments, votes, and subreddit metadata. The installer creates a database named artemis with user artemis (password password) and registers custom SQL functions (hot, score, controversy, ip_network, base_url, domain) used by the ranking and listing code. Listens on port 5432.

Cassandra

Stores non-relational data including session tokens, the permacache, and wiki content. The installer creates a keyspace named artemis using SimpleStrategy with a replication factor of 1, and a permacache column family within it. The Artemis PPA ships Cassandra 1.2 via the DataStax repository. Listens on port 9160.

RabbitMQ

AMQP message broker used for background job queues (AutoModerator, vote processing, comment trees, search indexing, email, and more) and as the transport layer for the websocket service. The installer creates a vhost / and an artemis user with full permissions, and enables the management plugin. Listens on port 5672.

mcrouter / memcached

Memcached provides an in-process cache layer. mcrouter is a memcached proxy that routes requests to the memcached pool. The installer configures mcrouter as the cache front-end. Memcached listens on port 11211. The artemis-flush helper flushes all cache entries: echo flush_all | nc localhost 11211.

Solr

Powers the full-text search provider. The r2 codebase ships a SolrSearchProvider registered as solr in r2.provider.search. Search queue consumers (search_q) are set to 0 by default and must be enabled explicitly if you want search indexing.

Zookeeper

Provides distributed coordination. The installer installs Zookeeper and the kazoo Python client. Zookeeper is used internally for leader election and distributed locking. The CI configuration uses jplock/zookeeper:3.4.6. Listens on the standard port 2181.

Redis

Redis is installed alongside the other services and is available for use by application code and plugins. It is installed via apt as redis-server.

nginx and haproxy

nginx serves media files (port 9000), the pixel/click tracking endpoints (port 8082), and terminates SSL (port 443, proxying to haproxy on 8080). haproxy fronts all HTTP traffic on port 80 and routes requests to the Artemis paster process, the websocket service, the nginx media backend, or the nginx pixel backend based on URL path and the Upgrade: WebSocket header.

Application services

artemis-service-websockets

artemis-service-websockets handles persistent WebSocket connections between browser clients and the server. It is primarily a broadcast service: it receives messages from other backend components and fans them out to connected clients. How it works:
  • Messages are published to a RabbitMQ fanout exchange. Each worker process binds a queue to the exchange and receives every published message.
  • Incoming WebSocket connections specify a namespace in the URL path. The service maps each message’s AMQP routing key to the matching namespace and delivers it to the appropriate connected sockets.
  • Incoming WebSocket requests must carry a message authentication code (MAC) that was signed by the main application. The service validates this MAC before accepting the connection — authorization itself is handled by the main app.
  • Optionally, the service publishes connect and disconnect notifications onto a separate AMQP topic exchange so that other consumers can react to session lifecycle events.
The service runs under Upstart on localhost:9001 via baseplate-serve2:
exec baseplate-serve2 --bind localhost:9001 $ARTEMIS_SRC/websockets/example.ini
haproxy routes requests carrying an Upgrade: WebSocket header to this backend automatically. Docker (development and testing):
# Run the websocket service locally, exposed on 127.0.0.1:9090
docker build . -t ws-server -f Dockerfile && docker run --rm -p 9090:9090 ws-server

# Run the test suite
docker build . -t ws-tests -f Dockerfile.test && docker run ws-tests

artemis-service-activity

artemis-service-activity provides real-time visitor counting for subreddits and threads. It is split into two components:
  • Main service — speaks the Thrift RPC protocol and handles the actual counting logic.
  • HTTP gateway — a thin HTTP front-end that translates HTTP requests into Thrift calls. This allows the main Artemis application to query visitor counts over plain HTTP.
The service runs under Upstart on localhost:9002:
exec baseplate-serve2 --bind localhost:9002 $ARTEMIS_SRC/activity/example.ini

Upstart service management

All Artemis runtime services are managed by Upstart. The installer writes configuration files to /etc/init/ and registers helper commands in /usr/local/bin/.

Helper commands

CommandEffect
artemis-startEmits artemis-start to bring up all services
artemis-stopEmits artemis-stop to shut down all services
artemis-restartEmits artemis-restart TARGET=all to restart everything
artemis-restart <name>Restarts only the named service (e.g. artemis-restart websockets)
artemis-flushFlushes all memcached entries
artemis-serveStarts the paster server in the foreground with --reload
artemis-shellOpens an interactive Pylons shell against run.ini
artemis-run -c '...'Runs a Python expression in the application context

Upstart jobs

The installer registers the following categories of Upstart jobs: Paster (main web process)
  • artemis-paster.conf — the primary Pylons application process
Queue consumers — each is configurable via a count file in $ARTEMIS_CONSUMER_CONFIG (defaults to ~/consumer-count.d/):
JobDefault count
artemis-consumer-commentstree_q1
artemis-consumer-vote_link_q1
artemis-consumer-vote_comment_q1
artemis-consumer-newcomments_q1
artemis-consumer-markread_q1
artemis-consumer-scraper_q1
artemis-consumer-del_account_q1
artemis-consumer-butler_q1
artemis-consumer-author_query_q1
artemis-consumer-branch_query_q1
artemis-consumer-domain_query_q1
artemis-consumer-search_q0 (disabled)
artemis-consumer-automoderator_q0 (disabled)
Scheduled jobs — run via cron, triggered through Upstart’s start command:
  • artemis-job-broken_things, artemis-job-rising, artemis-job-trylater, artemis-job-update_promos, artemis-job-clean_up_hardcache, artemis-job-update_sr_names, artemis-job-update_branches, and others.
search_q and automoderator_q consumers are set to 0 by default. To enable them, update the count files in your consumer-count.d directory and restart the consumers.

Security disclaimer

Artemis does not make any claims about the security or reliability of this software and is not liable if you are compromised. Portions of this code and assets are © 2005–2015 reddit Inc. If you discover a vulnerability, contact artemis@cocaine.ninja for assistance or ethical disclosure.

Build docs developers (and LLMs) love