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.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.
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 viaapt 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 theUpgrade: 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.
localhost:9001 via baseplate-serve2:
Upgrade: WebSocket header to this backend automatically.
Docker (development and testing):
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.
localhost:9002:
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
| Command | Effect |
|---|---|
artemis-start | Emits artemis-start to bring up all services |
artemis-stop | Emits artemis-stop to shut down all services |
artemis-restart | Emits artemis-restart TARGET=all to restart everything |
artemis-restart <name> | Restarts only the named service (e.g. artemis-restart websockets) |
artemis-flush | Flushes all memcached entries |
artemis-serve | Starts the paster server in the foreground with --reload |
artemis-shell | Opens 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
$ARTEMIS_CONSUMER_CONFIG (defaults to ~/consumer-count.d/):
| Job | Default count |
|---|---|
artemis-consumer-commentstree_q | 1 |
artemis-consumer-vote_link_q | 1 |
artemis-consumer-vote_comment_q | 1 |
artemis-consumer-newcomments_q | 1 |
artemis-consumer-markread_q | 1 |
artemis-consumer-scraper_q | 1 |
artemis-consumer-del_account_q | 1 |
artemis-consumer-butler_q | 1 |
artemis-consumer-author_query_q | 1 |
artemis-consumer-branch_query_q | 1 |
artemis-consumer-domain_query_q | 1 |
artemis-consumer-search_q | 0 (disabled) |
artemis-consumer-automoderator_q | 0 (disabled) |
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, contactartemis@cocaine.ninja for assistance or ethical disclosure.