Background Solr Indexing - Run Drupal Indexing as Daemon

Daemon mode that survives SSH disconnection

Background Mode

Background mode is the default since v2.5. The indexer automatically runs as a daemon that survives SSH disconnection. Use --no-background for foreground mode.

# Starts in background by default
drush ost --server=my_solr_server

# Check progress anytime
drush oss

# Watch the log file (server-specific)
tail -f /tmp/opensolr_turbo_my_solr_server.log

# Stop when needed
drush osstop
📝 Log Location
Each session gets its own log file: /tmp/opensolr_turbo_{server}.log. When indexing a specific index, the log includes the index name: /tmp/opensolr_turbo_{server}__{index}.log.

How Background Mode Works

The indexer (default behavior):

  1. Starts a daemon process using nohup
  2. Detaches from your terminal session
  3. Writes progress to a per-session log file instead of stdout
  4. Continues running even if you disconnect

Monitoring Background Jobs

Check Status

Use drush oss to see current progress:

drush oss

=== INDEXING STATISTICS ===

  Server: my_solr_server
    my_solr_index          [##########..........] 52.3%
      156,432 / 299,123 (remaining: 142,691)

  Background indexer running (PID: 12345)
  Log: /tmp/opensolr_turbo_my_solr_server.log

  Active workers: 10

Watch the Log

For detailed real-time progress (use the server-specific log):

tail -f /tmp/opensolr_turbo_my_solr_server.log

The log shows updates every 5 seconds with:

  • Current time and elapsed duration
  • Number of active workers
  • Progress percentage for each index
  • Indexing rate (items/second)
  • Estimated time remaining (ETA)

Stop Background Indexing

drush osstop

This stops both the master daemon and all worker processes cleanly.

Process Management

Find Running Processes

# Find master process for a specific server
cat /tmp/opensolr_turbo_my_solr_server_master.pid

# List all master PIDs
ls /tmp/opensolr_turbo_*_master.pid

# List all worker processes
ps aux | grep 'opensolr:worker'

# Count active workers
ps aux | grep 'opensolr:worker' | grep -v grep | wc -l

Emergency Stop

If drush osstop doesn't work:

# Kill all master processes
for f in /tmp/opensolr_turbo_*_master.pid; do kill $(cat "$f") 2>/dev/null; done

# Kill all workers
pkill -f 'opensolr:worker'

# Clean up PID files
rm -f /tmp/opensolr_turbo_*_master.pid /tmp/opensolr_turbo_*.pids
💡 Multiple Instances
You can run multiple background indexers simultaneously — one per server or per index. Each session is fully isolated with its own PID files, logs, and chunk directories.