Background Solr Indexing That Survives SSH Disconnects

The default mode, its log and the site address

Background mode

Since version 2.5, drush ost runs in the background by default. It starts a separate Drush process and gives you your terminal back; that process keeps indexing after you close the terminal or log out of SSH.

drush ost --server=my_solr_server
drush oss
tail -f /tmp/opensolr_turbo_my_solr_server.log
drush osstop

The log

Everything the background process prints goes to the session's log: /tmp/opensolr_turbo_{server}.log, or /tmp/opensolr_turbo_{server}__{index}.log for a run with --index. Each run adds to the end of it; the indexer never empties it.

Server:  my_solr_server
Workers: 10 (true parallel)
Batch:   200 items/worker
Round:   2000 items/round

Indexes:
  content_index                     299,123 remaining

Processing index: content_index
   Round 1: fetched 2000 items
   Waiting for 10 workers...
   [....................]   0.7% | 2,000 indexed | 154/s | ETA: 32m 11s
   Round 2: fetched 2000 items
   Waiting for 10 workers...
   [....................]   1.3% | 4,000 indexed | 154/s | ETA: 31m 58s
  • One progress line per round, written when every worker of the round has finished: percent done, items indexed in this run, items per second, time left.
  • At the end: INDEXING COMPLETE, the duration, and a summary per index.
  • Worker errors start with [OpenSolr Worker]. They land in this log unless your command-line PHP sends errors to a file of its own.

In the terminal instead

drush ost --server=my_solr_server --no-background

The same lines appear on your screen. Ctrl+C stops it, and so does closing the terminal.

Your site's address

If your index has fields built from the site address (tokens such as [site:url]), the workers need the real address, not http://default. The background process starts without the --uri you typed, so put the address in your project's Drush config, which every Drush process reads:

# drush/drush.yml, next to vendor/ in your project
options:
  uri: 'https://www.example.com'

In the terminal mode, drush --uri=https://www.example.com ost --no-background also works: the workers get the address you pass.

Everyday tasks