Class: Sunspot::Rails::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/sunspot/rails/server.rb

Overview

The Sunspot::Rails::Server class is a simple wrapper around the start/stop scripts for solr.

Constant Summary collapse

SUNSPOT_EXECUTABLE =

Name of the sunspot executable (shell script)

(RUBY_PLATFORM =~ /w(in)?32$/ ? 'sunspot-solr.bat' : 'sunspot-solr')

Class Method Summary collapse

Class Method Details

.bootstrapObject

Bootstrap a new solr_home by creating all required directories.

Returns

Boolean

success



104
105
106
# File 'lib/sunspot/rails/server.rb', line 104

def bootstrap
  create_solr_directories and create_solr_configuration_files and copy_custom_solr_libraries
end

.bootstrap_neccessary?Boolean

Check for bootstrap necessity

Returns

Boolean

neccessary

Returns:

  • (Boolean)


115
116
117
# File 'lib/sunspot/rails/server.rb', line 115

def bootstrap_neccessary?
  !File.directory?( solr_home ) or !File.exists?( File.join( config_path, 'solrconfig.xml' ) )
end

.config_pathObject

Directory to store solr config files

Returns

String

config_path



59
60
61
# File 'lib/sunspot/rails/server.rb', line 59

def config_path
  File.join( solr_home, 'conf' )
end

.data_pathObject

Directory to store lucene index data files

Returns

String

data_path



70
71
72
# File 'lib/sunspot/rails/server.rb', line 70

def data_path
  File.join( solr_home, 'data', ::Rails.env )
end

.lib_pathObject

Directory to store custom libraries for solr

Returns

String

lib_path



81
82
83
# File 'lib/sunspot/rails/server.rb', line 81

def lib_path
  File.join( solr_home, 'lib' )
end

.pid_pathObject

Directory to store pid files

Returns

String

pid_path



92
93
94
# File 'lib/sunspot/rails/server.rb', line 92

def pid_path
  File.join( solr_home, 'pids', ::Rails.env )
end

.runObject

Run the sunspot-solr server in the foreground. Boostrap solr_home first, if neccessary.

Returns

Boolean

success



36
37
38
39
# File 'lib/sunspot/rails/server.rb', line 36

def run
  bootstrap if bootstrap_neccessary?
  execute( run_command )
end

.startObject

Start the sunspot-solr server. Bootstrap solr_home first, if neccessary.

Returns

Boolean

success



23
24
25
26
# File 'lib/sunspot/rails/server.rb', line 23

def start
  bootstrap if bootstrap_neccessary?
  execute( start_command )
end

.stopObject

Stop the sunspot-solr server.

Returns

Boolean

success



48
49
50
# File 'lib/sunspot/rails/server.rb', line 48

def stop
  execute( stop_command )
end